Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
ludwik
2 days ago
|
parent
|
context
|
favorite
| on:
Simulating the Ladybug Clock Puzzle
Shouldn't the code say:
position = (position + direction + 1) % 12;
Or have I misunderstood something?
LiamPowell
2 days ago
|
next
[–]
The +12 is to keep the number positive. The direction contains the movement so a +1 wouldn't make sense.
reply
nulptr
2 days ago
|
prev
[–]
The +12 there is so that % works correctly (ie the number never becomes negative)
reply
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: