Infinite Spiral of Numbers (due 20 Nov 2017)

Consider the natural numbers laid out in a square spiral, with 1 occupying the center of the spiral. The central 11 x 11 subset of that spiral is shown in the table below.

111112113114115 116117118119120121
11073747576 777879808182
10972434445 464748495083
10871422122 232425265184
1077041207 8910275285
1066940196 1211285386
1056839185 4312295487
10467381716 151413305588
10366373635 343332315689
10265646362 616059585790
101100999897 969594939291

This spiral has several interesting features. The southeast diagonal has several prime numbers (3, 13, 31, 57, and 91) along it. The southwest diagonal has a weaker concentration of prime numbers (5, 17, 37) along it.

To construct the spiral we start with 1 at the center, with 2 to the right, and 3 below it, 4 to the left, and so on. A part of the problem for this assignment is to figure out the rule to fill the spiral for an arbirary size. Once you have that rule you can complete the rest of the assignment.

You will prompt the user for the following information:

Enter dimension: 57
Enter number in spiral: 42
The first line indicates the dimension of the square spiral. This number should be an odd number. If it is not then choose the dimension to be the next higher odd number. The second number must be in the range 1 and the square of the dimension. If the second number is not in that range, print an error message Number not in Range and exit the program.

You will write the neigboring numbers of the second number in three lines. Each line will have three integers separated by a single white space. If the second number was 42, then this should be your output:


72 43 44
71 42 21
70 41 20

If the second number was 64, then this should be your output:

66 37 36
65 64 63
100 99 98

What if that second number was on the outer edge of the spiral, then print Number on Outer Edge.

For this assignment you may work with a partner. Both of you must read the paper on Pair Programming. .

The file that you will be turning in will be called Spiral.py. The file will have a header of the following form:

#  File: Spiral.py

#  Description:

#  Student Name:

#  Student UT EID:

#  Partner Name:

#  Partner UT EID:

#  Course Name: CS 303E

#  Unique Number: 

#  Date Created:

#  Date Last Modified:

If you are working with a partner both of you will be submitting a single program (from either account) but make sure that you have your partner's name and eid in your program. If you are working alone, then remove the two lines that has the partner's name and eid in the header.

Use the Canvas program to submit your Spiral.py file. We should receive your work by 11 PM on Monday, 20 Nov 2017. There will be substantial penalties if you do not adhere to the guidelines.