Background from #36 (part 1):

Imagine arranging the positive integers in a spiral pattern.

The numbers from 1 to 16 look like this in the spiral pattern.

10 9 8 7

11 2 1 6

12 3 4 5

13 14 15 16

The location of each number corresponds to an X,Y Cartesian coordinate where the number 1 is at the origin: (0,0). 2 is at (-1,0). 3 is at (-1,-1). 4 is at (0,-1). 5 is at (1,-1). 6 is at (1,0). 7 is at (1,1) and so on.

Here's this week's contest problem:- Come up with an algorithm that tells what number is at an arbitrary X, Y coordinate.
- Come up with an algorithm that tells the X, Y coordinates for an arbitrary positive integer.

## No comments:

## Post a Comment