Question: read_coords (s): Given a GridString s, read through it and create a list of int pairs for all live cells Each pair is a (row,

 read_coords (s): Given a GridString s, read through it and createa list of int pairs for all live cells Each pair isa (row, column) coordinate. If the rows don't all have the samenumber of spots indicated, or if any unexpected characters are present, thisfunction returns None. Must be ordered by lowest row and lowest columnwhen rows match. o Assume: s is a GridString o Hint: s.split)is your friend. What should you split by? o read_coords("o..n.00 ") read-coords("inino..

read_coords (s): Given a GridString s, read through it and create a list of int pairs for all live cells Each pair is a (row, column) coordinate. If the rows don't all have the same number of spots indicated, or if any unexpected characters are present, this function returns None. Must be ordered by lowest row and lowest column when rows match. o Assume: s is a GridString o Hint: s.split) is your friend. What should you split by? o read_coords("o..n.00 ") read-coords("inino.. .00 ") [(8,0), (1,1), (1,2)] # ignore blank lines o get_dimensions (s): Given a GridString s, find out how many rows and columns are represented in the GridString, and return them as a tuple: (numrows, numcols). Remember that any blank lines must be ignored (skipped). If the rows don't all have the same number of items in them, or any unexpected characters are present, this function returns None. o Assume: s is a GridString o get_dimensions ("O. . .00 ") o get-dimensions("00000 00 ") o get dimensions(" oo .. .o no.In..In ") None (5,2) #not rectangular ! # note ignored blank lines build_empty_grid(height, width): Given positive int values for the height and width of a grid, create a Grid that has False values at each location (representing dead cells) o Assume: height and width are positive integers o build, empty-grid (2,3) [[False, False, False], [False, o build-empty-grid (1,4) build, empty-grid(3,1) [[False], [False], [False]] o build-empty-grid(1,3) [[False, False, False]] False, False]] [[False, False, False, Falsell build_grid(s): Given a GridString s, determine the dimensions, build a grid of that size, and make alive each cell that should be alive. Assume: s is a GridString Hint: try to use read_coords, get_dimensions, and build_empty_grid in your solution. o build grid("o.. .oo ") o o [False, True], False, True]] [[True, [[False, False], False], [True, True, False, True, False, False True, [True, [False, True]] o build-grid(".. .o 00 ") o build grid("00.0..") show-grid (grid, live-'0' , dead-'') : Given a Grid, and the option to indicate what representation . to use for live and dead cells, create the GridString that has no blank lines in it and represents the indicated grid. o Assume: grid is a Grid; live and dead are strings. o Hint: You'll likely want to call print (show_grid (someGrid)) when trying it out. o show_grid(I[True, False, False], [False, True, True]]) o show_grid([[False, False], [True, True]]) o show_grid([[False, False], [True, True]], 'A', '#) o show grid([]) "O..n.00 n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!