10 ms·
Fifty Fizzbuzzes
- spatten 8y agoThe Jupyter notebook is here: https://mybinder.org/v2/gh/quasiben/fiftyfizzbuzzes/master?filepath=Fifty%20Fizzbuzzes.ipynb https://mybinder.org/v2/gh/quasiben/fiftyfizzbuzzes/master?f... The code on GitHub is here: https://github.com/vihart/fiftyfizzbuzzes/blob/master/Fifty%20Fizzbuzzes.ipynb https://github.com/vihart/fiftyfizzbuzzes/blob/master/Fifty%...
- grahamotte 8y agoWe've killed it.
- Retr0spectrum 8y agohttps://web.archive.org/web/20181101043107/vihart.com/fifty-fizzbuzzes/ https://web.archive.org/web/20181101043107/vihart.com/fifty-...
- romwell 8y agoVi's site is down from the onslaught. In the meantime, enjoy the ever-classic Fizz Buzz Enterprise Edition: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
- AceJohnny2 8y agoAlso FizzBuzz in TensorFlow: http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/ http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
- toxik 8y agoI opened the link thinking ”hah, what a gag!” But then I thought it’d be funny to try to find the core fizzbuzz logic. Turns out that it hits way too close to home, I just got really annoyed. Not sure what I expected.
- romwell 8y agoI think it's a work of art, and your feelings corroborate this opinion :)
- userbinator 8y agoBut then I thought it’d be funny to try to find the core fizzbuzz logic. The point is that there is no "core" logic anymore. It's been broken down and spread out over a dozen files, each of which does "one and only one (tiny) thing" according to the "best practices" of problem decomposition. Then all the pieces are glued together again using design patterns.
- quickthrower2 8y agoIt does hit close to home. I've seen all that code in one form or another. The "adapter" that ignores exceptions made me chuckle though. But like enterprise code I've seen before I have no chance of finding that class again although I am sure it exists.
- Mikkeren 8y agoAs the original author, I apologize for your agony. This is a common complaint from people I discussed the project with, and the obvious reason for the success of the project in terms of people contributing patches and issues.
- userbinator 8y agoNot too long ago I had to deal with C# in the same style, which reminded me of it; and not surprisingly, there's also a C# version: https://github.com/jongeorge1/FizzBuzzEnterpriseEdition-CSharp https://github.com/jongeorge1/FizzBuzzEnterpriseEdition-CSha...
- tonyedgecombe 8y agoOr if you want to abuse dynamic and lambdas in C#: https://github.com/tonyedgecombe/functionalfizzbuzz/blob/master/FunctionalFizzBuzz/FunctionalFizzBuzz.cs https://github.com/tonyedgecombe/functionalfizzbuzz/blob/mas...
- Retr0spectrum 8y agoThe python notebook linked in the main post: https://mybinder.org/v2/gh/quasiben/fiftyfizzbuzzes/master?filepath=Fifty%20Fizzbuzzes.ipynb https://mybinder.org/v2/gh/quasiben/fiftyfizzbuzzes/master?f...
- deleted 8y ago[deleted]
- pmoriarty 8y agoI was kind of hoping these would be lessons learned from looking over 50 solutions to fizzbuzz from 50 different programmers. That might have been amusing. Instead it's just sombody's random programming exercises.
- ummonk 8y agoThis is where the actual fizz buzzes are: https://github.com/vihart/fiftyfizzbuzzes/blob/master/Fifty%20Fizzbuzzes.ipynb https://github.com/vihart/fiftyfizzbuzzes/blob/master/Fifty%...
- bytematic 8y agoNote also that not all of them are correct :)
- sirsuki 8y agoWhy does static content need a database connection? #OverEngineering
- Kerrick 8y agoThe entire blog post is about how to over-engineer FizzBuzz for fun and learning.
- packetslave 8y agoUsing WordPress is "over-engineering"?
- dr_teh 8y agoYes
- egypturnash 8y agoMore or less so than running a static site generator that lives on one particular machine, and using Git to push your changes to the server?
- influx 8y agoMore like use a static generator to push to S3, optionally with a Cloudfront distribution in front of it.
- quickthrower2 8y agoWordPress should include a cache switched on by default then you have to turn it OFF as an advanced setting. That'd be good for performance and the environment :-) But using Wordpress is no more overengineering than buying a car. (Versus building your own 2 stroke engine because it's simpler).
- pjc50 8y agoWordpress is under-engineering. It's what you default to when you don't want to do any engineering and just deploy the standard blog solution that everyone's familiar with.
- ErikAugust 8y agoOne done over my lunch break today: https://gist.github.com/ErikAugust/67e61de02702b37ed04deea24452a534 https://gist.github.com/ErikAugust/67e61de02702b37ed04deea24...
- geraldbauer 8y agoFYI: You find 20+ in the FizzBuzz by Example - There's More Than One Way To Do It (Free Online Book Edition) - http://yukimotopress.github.io/fizzbuzz http://yukimotopress.github.io/fizzbuzz
- 333c 8y agoThis is called out in the post, but 32 is actually a really cool rhythmic (and accurate) fizzbuzz.
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]
- codereflection 8y agoI like this idea. I find it fascinating how many developers I've interviewed who still have not come across FizzBuzz, and how many of those cannot solve the problem. Some of the more interesting interviews I've given though have been with people who know the FizzBuzz problem, where I ask them to make the worst possible version of it that they can. It turns out to be more difficult than they think it will be, and a deeper thinking and communicating exercise than solving the simple FizzBuzz problem itself.
- jtolmar 8y agolet tokens = []; tokens.push("Fizz", "Buzz", "Fizzbuzz"); for (let i = 0; i <= 100; i++) { tokens.push(i); } function generateFizzBuzz(n) { if (n > 100) { return [[]]; } let result = []; for (let token of tokens) { for (let tail of generateFizzBuzz(n+1)) { tail.splice(0, 0, token); result.push(tail); } } return result; } let candidates = generateFizzBuzz(1); while (candidates.length > 1) { let candidateIndex = Math.floor(Math.random() * candidates.length); let candidate = candidates[candidateIndex]; let checkIndex = Math.floor(Math.random() * 100); let expected = checkIndex % 3 == 0 ? (checkIndex % 5 == 0 ? "Fizzbuzz" : "Fizz") : (checkIndex % 5 == 0 ? "Buzz" : checkIndex); if (candidate[checkIndex] !== expected) { candidates.splice(candidateIndex, 1); } } return candidates[0];
- a1369209993 8y ago> the worst possible version of it that they can Based on a true story, sadly: #! /usr/bin/tail -n+2 1 2 Fizz 4 Buzz [...] 98 Fizz Buzz On the other hand, there's also ones like: let{a="ssfsbfssfbsfssX"++a;x 's'=show;x 'f'=const"Fizz";x 'b'=const"Buzz";x 'X'=const"FizzBuzz"}in putStrLn$concat$map(\(i,f)->x f i++"\n")(zip[1..100]a) (because who needs divisibility tests, right?)
- Waterluvian 8y agoCan't solve because they weren't actually programmers or more because of deer in headlights?
- 8y ago
- tracker1 8y agoHere's mine: Array.from(new Array(100)).forEach((_, i)=>++i&&console.log(((i%3?"":"Fizz")+(i%5?"":"Buzz"))||i)) https://twitter.com/tracker1/status/1045475226128007169 https://twitter.com/tracker1/status/1045475226128007169
- stevekemp 8y agoI just committed a version that works in my golang BASIC interpreter: https://github.com/skx/gobasic/blob/master/examples/15-fizz-buzz.bas https://github.com/skx/gobasic/blob/master/examples/15-fizz-... Perhaps not the cleanest, since I support neither `CASE` nor `ELSE IF`. But it seems to be correct.
- deleted 8y ago[deleted]
- daphneokeefe 8y agoHere's my long-ago contribution. Scroll down for the visual. https://codepen.io/daphneokeefe/pen/Ayxlz https://codepen.io/daphneokeefe/pen/Ayxlz
- tne 8y ago#include <stdlib.h> #include <stdio.h> static const char str[] = "fizzbuzz"; static inline void out(int i, size_t offset, size_t sz) { if (sz) { fwrite(str + offset, sz, 1, stdout); } else { fprintf(stdout, "%d", i); } putchar('\n'); } int main(void) { for (int i = 1; i <= 100; i++) { int a = i % 3 == 0; int b = i % 5 == 0; out(i, 4*((a^b)&b), 4*(a+b)); } exit(0); } There's a way to remove that conditional, too. Probably.
- emmelaich 8y agoI didn't know that fizzbuzz was a children's game. That explains a LOT. As in most descriptions of it are annoyingly ambiguous. Whereas if you knew the game, you know it already.
- thrmsforbfast 8y ago> As in most descriptions of it are annoyingly ambiguous. My very first interviewer (intentionally) didn't spec fizzbuzz correctly. The real test was whether the candidate listened to the customer's/lead engineer's spec instead of jumping to conclusions. Fortunately, I was just entering college and hadn't heard of fizzbuzz before. I passed the "test" but for the wrong reason.
- segh 8y agoBeing purposely misleading then penalising those who are misled doesn't seem like a good hiring strategy, but then again, I've never tried to hire someone.
- sincerely 8y agoI feel like everyone leaving a fizzbuzz solution in the comments of this post is missing the point of this article...
- jpindar 8y agoFizzbuzz does that to some people. It's a mind-control meme, and a very powerful one.
- pronoiac 8y agoWayback Machine mirror: https://web.archive.org/web/20181101043107/http://vihart.com/fifty-fizzbuzzes/ https://web.archive.org/web/20181101043107/http://vihart.com...
- bakul 8y ago{:[~x!15;"fizzbuzz";~x!3;"fizz";~x!5;"buzz";$x]}'1+!100 {:[0<#w::[x!3;"";"fizz"],:[x!5;"";"buzz"];w;$x]}'1+!100
- bakul 8y agoAre there any shorter programs than these two k3 ones?
- wodenokoto 8y agoIs this the same vihart of YouTube hexaflexagon fame? https://youtu.be/VIVIegSt81k https://youtu.be/VIVIegSt81k
- ygra 8y agoYes.
- tzs 8y agoHN user aidenn0 won FizzBuzz a few years ago, with a Malbolge [1] version: https://news.ycombinator.com/item?id=4922282 https://news.ycombinator.com/item?id=4922282 [1] https://en.wikipedia.org/wiki/Malbolge https://en.wikipedia.org/wiki/Malbolge
- xxs 8y agoA small exercise: write Spectre/timing attacks resilient fizzbuzz.
- equalunique 8y agoVi Hart's YouTube channel is quite entertaining: https://www.youtube.com/user/Vihart https://www.youtube.com/user/Vihart