CCC '01 S2 - Spirals

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
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


Sample Output 1

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

Sample Input 2


Sample Output 2

12 11
 7 10
 8  9


  • -1
    tepen9248  commented on Dec. 24, 2019, 11:37 a.m.

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

    • 1
      c  commented on Dec. 24, 2019, 1:48 p.m.


  • 0
    xzorcism  commented on Feb. 5, 2018, 6: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

    • 3
      Xyene  commented on Feb. 5, 2018, 9:50 p.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
    trollakatroll  commented on June 25, 2017, 1:22 p.m. edited


  • -2
    Juex  commented on Feb. 20, 2017, 9:17 p.m.

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

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

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

    • -1
      trollakatroll  commented on June 25, 2017, 1:52 p.m. edited

      have you tried different testcases? maybe that will help. i think i might know the bug in your code. just keep on trying different testcases and i think you will get it

  • 6
    xXxP0t4t0MStRxXx  commented on Oct. 29, 2016, 8:50 p.m.

    what is the ` in output 1