Comment

Comment by aristus

  cases = (
    (3, 'Fizz'),
    (5, 'Buzz'),
    (7, 'Bazz'),
    (11, 'Boo'),
    (13, 'Blip'),
  )

  for i in range(1, 101):
      out = []
      for c in cases:
          if i % c[0] == 0:
              out.append(c[1])
      if out:
          print ''.join(out)
      else:
          print i

Edit: not to detract from the post's point, I think it's valid. Monoids are cool and all but simple counting arguments can take you a long, long, long, way when case analysis fails you.
parent aristus 14 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton