CCC '01 S2 - Spirals

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2001 Stage 1, Junior #4, Senior #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 x 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 centre. 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

Comments


  • 21
    Nils_Emmenegger  commented on Jan. 22, 2021, 8:01 p.m.

    Leading and trailing whitespace do not matter. In other words: as long as the right numbers are on the right line in the right order, then it is correct, unlike some other questions which are a bit more strict with output (e.g. ccc00j1).


  • 1
    tepen9248  commented on Dec. 24, 2019, 4:37 p.m.

    this is ridiculous i wanna use numpy but it gives module no found error


  • 5
    xzorcism  commented on Feb. 5, 2018, 11:57 p.m.

    I tend to use Turing a lot for some questions due to how fast it can solve questions, but it seems that the DMOJ Turing Judge doesn't really allow the Text.Locate method to work and constantly produces IR as a result. I can work around that of course, but was just wondering why the DMOJ Turing Judge seems to dislike Text.Locate


    • 9
      Xyene  commented on Feb. 6, 2018, 2:50 a.m. edited

      The DMOJ is primarily a text-based input/output system, so using standard IO methods is required. Text.Locate functionality is fundamentally unsupported at the operating system level for file streams.


  • -3
    Juex  commented on Feb. 21, 2017, 2:17 a.m.

    My code works for all the other cases expect test case #1, anybody know why?


    • 2
      AlexCress  commented on Dec. 4, 2017, 7:24 a.m.

      I'm sure you have figured it out by now, but for anyone else: x == y.