Spiral Function
Map integers to coordinates in a spiral pattern
Problem Statement
A spiral function maps a nonnegative integer n onto integer coordinates (x, y) in a spiral pattern on a Cartesian plane. The spiral starts at the origin (0, 0) with n = 0 and expands outward in a counter-clockwise direction.
Write a function spiralCoordinates(n) that takes an integer n and returns its coordinates (x, y) in the spiral.
Exa…
Keep reading with a 7-day free trial
Subscribe to Puzzle Spree to keep reading this post and get 7 days of free access to the full post archives.


