Literally a (generalized) two-line version of FizzBuzz (pastebin.com) 1 points by thanatropism 7y ago ↗ HN
[–] QuantumAphid 7y ago ↗ Today I learned that 4 lines of code is allowed to be billed as 2 lines of code.
[–] schoen 7y ago ↗ I 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 7y ago ↗ Source title is “Untitled”, and while unhelpful, is more accurate, as, whatever this is, it is not literally a two line version of anything.
3 comments
[ 3.0 ms ] story [ 12.2 ms ] thread