4 ms·
The "Haskell implementation using monoids" on this page is the only solution I've seen where adding a new behavior (e.g. "FizzBuzzWoof") only requires a modific
by happimess 8y ago
The "Haskell implementation using monoids" on this page is the only solution I've seen where adding a new behavior (e.g. "FizzBuzzWoof") only requires a modification in one spot.
(d 3 "Fizz" <> d 5 "Buzz")
becomes
(d 3 "Fizz" <> d 5 "Buzz" <> d 13 "Woof")
eta: And just below it is a similar solution in Python. Cool!
- duckerude 8y agoWith similar properties, but more disgusting: for n in range(1, 101): print(n, end='\r') if n % 3 == 0: print("Fizz", end='') if n % 5 == 0: print("Buzz", end='') print()
- drfuchs 8y agoExtra points for deviousness, but this won't produce the correct visual result when logged in on a hardcopy terminal (e.g. DECwriter); or even on a glass tty (e.g. DEC VT100) if you set the upper limit to 10001. It will also always fail a correctness test of diffing against the proper output. You should definitely consider entering the Obfuscated C contest, though.