Sep-25-2020, 06:19 PM
(This post was last modified: Sep-26-2020, 01:38 PM by deanhystad.)
This is a pencil and paper exercise and has almost nothing to do with Python lists other than knowing how to make and index a 2D list.
With pencil and paper draw an empty 2D list. The list below is for n=4
Continue filling down along the right side of the square.
Fill across the bottom.
How about fill in the rest of the square.
Once you have the rules figured out for making any sized square, you will convert your rules into Python. This is the easy part of this assignment.
With pencil and paper draw an empty 2D list. The list below is for n=4
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __Start from the upper left corner begin filling out the list and write down the Python code to do the equivalent.
_1 _2 _3 _4 s[0][0] = 1, s[0][1] = 2, s[0][2] = 3, s[0][3] = 4 __ __ __ __ __ __ __ __ __ __ __ __Can this be generalized to some equation or rule?
Continue filling down along the right side of the square.
_1 _2 _3 _4 s[0][0] = 1, s[0][1] = 2, s[0][2] = 3, s[0][3] = 4 __ __ __ _5 s[1][3] = 5, s[2][3] = 6, s[3][3] = 7 __ __ __ _6 __ __ __ _7Is there a pattern or rule for why we are filling downward? What caused the change from filling to the right to filling down?
Fill across the bottom.
_1 _2 _3 _4 s[0][0] = 1, s[0][1] = 2, s[0][2] = 3, s[0][3] = 4 __ __ __ _5 s[1][3] = 5, s[2][3] = 6, s[3][3] = 7 __ __ __ _6 s[3][2] = 8, s[3][1] = 9, s[3][0] = 10 10 _9 _8 _7Any pattern or rule here? How long do we fill to the left? Why did we stop filling down?
How about fill in the rest of the square.
_1 _2 _3 _4 s[0][0] = 1, s[0][1] = 2, s[0][2] = 3, s[0][3] = 4 12 13 14 _5 s[1][3] = 5, s[2][3] = 6, s[3][3] = 7 11 16 15 _6 s[3][2] = 8, s[3][1] = 9, s[3][0] = 10 10 _9 _8 _7 s[2][0] = 11, s[1][0] = 12 s[1][1] = 13, s[1][2] = 14 s[2][2] = 15 s[2][1] = 16Repeat the exercise for a 5x5 square. Look for patterns or rules. Maybe there will be a pattern for even sized squares and a different pattern for odd sized squares. Maybe a size 4 square is a "skin" wrapped around a size 2 square. Maybe there is a simple set of rules that describe how to fill the next cell.
Once you have the rules figured out for making any sized square, you will convert your rules into Python. This is the easy part of this assignment.