Return to Video

06-31 Horizontal Plays

  • 0:00 - 0:05
    Now let's do a little bit of planning. We did row plays. What is row play return?
  • 0:05 - 0:10
    Well, it's a set of plays where each play is an i-word pair, where i is the index
  • 0:10 - 0:13
    into the row where the word starts. We eventually want to get all plays.
  • 0:13 - 0:18
    Before we can get there, I'm going to introduce another function called horizontal plays,
  • 0:18 - 0:22
    which does row plays across all the possible rows,
  • 0:22 - 0:25
    but only going in the across direction not in the down direction.
  • 0:25 - 0:31
    That'll take a hand and a board as input. A board is just a list of rows.
  • 0:31 - 0:38
    It'll return a set of plays where a play, like in a row play, is the position in the word
  • 0:38 - 0:44
    except now the position is not going just to be i, the position is an i-j pair.
  • 0:44 - 0:50
    It's going to be at this column in this row along with the word.
  • 0:50 - 0:54
    It's a set of tuples that look like that. Let's define horizontal plays.
  • 0:54 - 0:58
    Well, you know the drill by know--familiar structure. We start out with an empty set of results.
  • 0:58 - 1:01
    We're going to build them up somehow and then get the results.
  • 1:01 - 1:06
    Now, how are we going to do that? Let's enumerate over all the rows in the board.
  • 1:06 - 1:09
    We just want the good ones--the one from 1 to -1.
  • 1:09 - 1:15
    We don't want the rows at the top and the bottom, which are off the board or the border squares.
  • 1:15 - 1:19
    For each good row, I'm going to write a function called set_anchors which takes the row
  • 1:19 - 1:24
    and modifies that row and mutates the row to have all the anchors in it.
  • 1:24 - 1:29
    Remember before when I called row plays I passed in manually all the anchors.
  • 1:29 - 1:31
    Here, I'm going to have the program do it for me.
  • 1:31 - 1:36
    Now, for each word, I want to find all the plays within that row
  • 1:36 - 1:39
    and properly add them in to results.
  • 1:39 - 1:44
    I want to do something with the row plays of hand within that row.
  • 1:44 - 1:47
    And I want you to tell me what code should go here.
  • 1:47 - 1:54
    It could be a single line or it could be a loop over the results that come back from row plays.
  • 1:54 -
    Figure out what goes here so that it can return the proper results.
Title:
06-31 Horizontal Plays
Description:

Other units in this course below:
Unit 1:http://www.youtube.com/playlist?list=PL818D7B4539EED6D3
Unit 2:http://www.youtube.com/playlist?list=PLB470B7816A914D87
Unit 3:http://www.youtube.com/playlist?list=PL2C981397711BDD5C
Unit 4:http://www.youtube.com/playlist?list=PL66FC120367E358C0
Unit 5:http://www.youtube.com/playlist?list=PL17BE79F86C9283AA
Unit 6:http://www.youtube.com/playlist?list=PL7B0DE2C0104F814D
Unit 7:http://www.youtube.com/playlist?list=PL6AE83B25FC53CEEF

Q&A: http://www.youtube.com/playlist?list=PLB8CD9F4159903D84

To gain access to interactive quizzes, homework, programming assignments and a helpful community, join the class at http://www.udacity.com

more » « less
Team:
Udacity
Project:
CS212 - Design of Computer Programs
Duration:
01:59
Amara Bot added a translation

English subtitles

Revisions