Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by ludwik

6 hours ago

Shouldn't the code say:

    position = (position + direction + 1) % 12;

Or have I misunderstood something?

2 comments

ludwik

Reply

LiamPowell  6 hours ago

The +12 is to keep the number positive. The direction contains the movement so a +1 wouldn't make sense.

nulptr  5 hours ago

The +12 there is so that % works correctly (ie the number never becomes negative)

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities