TORONTO KIDS COMPUTER CLUB | PMCA Friday 19:00 Python Homework 20.07.24.
18026
post-template-default,single,single-post,postid-18026,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Friday 19:00 Python Homework 20.07.24.

29 Jul PMCA Friday 19:00 Python Homework 20.07.24.

Question:

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 1
10
27

Sample Output 1
27 26
16 15 14 25
17 10 13 24
18 11 12 23
19 20 21 22

Sample Input 2
7
12

Sample Output 2
12 11
7 10
8 9

No Comments

Sorry, the comment form is closed at this time.