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

Comment by quietbritishjim

8 hours ago

Genuinely hard to tell if satire.

Just in case not, consider whether the short function

   def is_even(x):
      return (x%2) == 0

Handles a wider range of input conditions than the higher LOC function

   def is_even(x):
     if x == 0:
       return True
     if x == 2:
       return True
     if x == 4:
       return True
     ...
     return False

0 comments

quietbritishjim

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities