Hacker News new | ask | show | jobs
by throw0101c 845 days ago
> Instead of showing rules as a linear list, I'd suggest it's easier to visualise it as a tree, or simpler still, as a series of nested ifs.

Feel free to post a comment with ASCII art or (pseudo-)code. :)

1 comments

(gets 1978 copy of The C Programming Language off the shelf)

   if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
      [it's a leap year]
   else
      [it's not]
I remember this because it is where I first learned the extra rules, beyond just every 4th year.