TORONTO KIDS COMPUTER CLUB | PMCA Friday 19:00 Python Homework 20.08.07.
18123

# PMCA Friday 19:00 Python Homework 20.08.07.

## 11 Aug PMCA Friday 19:00 Python Homework 20.08.07.

Question:

Continue making the following program using solution 2:

A spiral of numbers can start and end with any positive integers less than 100. Write a program which will accept two positive integers x and y as input, and output a list of numbers from xx to y inclusive, shown in a spiral.  You may assume that the end value is greater than or equal to the start value.

A spiral starts with the first number in the center. The next number appears immediately below the first number. The spiral continues with the numbers increasing in a counter-clockwise direction until the last number is printed.

Sample Input 11027Sample Output 1      27 2616 15 14 2517 10 13 2418 11 12 2319 20 21 22

Sample Input 2712Sample Output 212 11 7 10 8  9

Hint of solution 2:
Use directions = ‘sdwa’ to solve the problem
We can create a variable called directionIndex and make it always equals to 0 to 3 which indicates the index in the variable direction.