loading...

re: Daily Challenge #5 - Ten Minute Walk VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Here is my JavaScript solution. My approach was to depart in some random direction, duplicate that initial set of directions, reverse each individ...
 

For wrapping some sum x + y inside of a range n, you can use (x + y) % n (and of course bounds-checking with if works too).

N.B. different languages treat negative mod differently. For JS, in the negative case you'd want something like ((x % n) + n) % n instead of plain %.

code of conduct - report abuse