4 ms·
Funny, every time I read "puzzle" or "brainteaser", I think, "I don't know why manhole covers are round," or "Who gives a shit that it took 7.612 seconds for my
by edw519 15y ago
Funny, every time I read "puzzle" or "brainteaser", I think, "I don't know why manhole covers are round," or "Who gives a shit that it took 7.612 seconds for my program to identify the 78,498 prime numbers less that 1,000,000." (Yes I know, get a life.)
But every time I read "FizzBuzz", I drop everything and go back to refactor my latest version, aspiring to get it down to one conditional.
- dpritchett 15y ago>> (1..100).each { |n| puts `curl -s fizzy.heroku.com/#{n}` }
- skrebbel 15y agowin!
- enceladus 15y agoThank you for inspiring me! I revisited my FizzBuzz just now and threw together this obscene Python one-liner. (If I write this kind of code in production, I should be a guaranteed "no-hire"!) from itertools import chain, combinations fizzbuzz = lambda n,terms: ((lambda d: d.update((x%d,w) for d,w in sorted(reduce(lambda (d0,w0),(d1,w1):(d0*d1,w0+w1),sorted(x)) for x in chain(*(combinations(terms.iteritems(),s) for s in xrange(1,len(terms)+1))))) or d)({0:str(x)})[0] for x in xrange(1,n)) print ', '.join(fizzbuzz(100,{3:'fizz',5:'buzz'}))
- talmand 15y agoI know why manhole covers are round and if that's the reason I got the job I don't know if I'd be happy with that. After all this FizzBuzzing I guess I should start writing one up just so I can say I've done it.
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]