Python Forum
Creating a circular matrix with one input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a circular matrix with one input
#3
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
__ __ __ __
__ __ __ __
__ __ __ __
__ __ __ __
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
__ __ __ _7
Is 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 _7
Any 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] = 16
Repeat 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.
Reply


Messages In This Thread
RE: Creating a circular matrix with one input - by deanhystad - Sep-25-2020, 06:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with a Matrix nxn with black and white input Rosko 3 2,013 Nov-24-2019, 07:39 AM
Last Post: buran
  Creating a wavelet matrix pingaan 4 2,543 May-26-2019, 06:25 PM
Last Post: heiner55
  define a diagonal matrix from a matrix amalalaoui 1 2,382 May-15-2019, 01:12 PM
Last Post: ichabod801
  Code for a circular wire?? hiphopopot0mous 11 6,683 Dec-03-2017, 06:23 PM
Last Post: micseydel
  Creating lists or arrays as the input nickalvar 4 4,267 May-03-2017, 04:46 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020