4 ms·
Literally a (generalized) two-line version of FizzBuzz
- QuantumAphid 8y agoToday I learned that 4 lines of code is allowed to be billed as 2 lines of code.
- schoen 8y agoI like how this solution uses several nice Python features; I found a way to simplify it further while still using the same overall approach: screams = {3: 'fizz',5:'buzz',21:'yaow'} for i in range(100): out = [screams[j] for j in screams if i%j == 0] print("".join(out) if out else i) Edit: here's an even shorter version: screams = {3: 'fizz',5:'buzz',21:'yaow'} for i in range(100): out = "".join(screams[j] for j in screams if i%j == 0) print(out or i)
- dragonwriter 8y agoSource title is “Untitled”, and while unhelpful, is more accurate, as, whatever this is, it is not literally a two line version of anything.