Anonymous asked: 1 in 3 show up and can't fizzbuzz. 1 in fucking _3_. Everyone has seen a cartoon I guess.
It is not hard to lie on a resume.
EDIT: Or just have different standards. In my last job, over 2½ years, I wrote maybe at most a hundred lines of Powershell. Do I put Powershell on my resume? Do I put two and a half years of Powershell on my resume?
ok but…..i don’t know how this works in real life but at least a lot of startups will have you solve something nontrivial before they talk to you
I always wonder how many failures to fizzbuzz are more about performance anxiety than lack of skill.
i mean, fizzbuzz is really easy, people who can fail to do it bc of performance anxiety should probably not have programming jobs
but it is also evil because it requires you to suppress your desire for elegance
it’s like, “code monkeys should just do exactly what theyre told and not have any aesthetic intuitions and basically wait around until good programmers can replace them with robots”
Can you unpack that a bit? Can a fizzbuzz implementation never be elegant? Also, I don’t think anyone is implying anything about what code should be like with fizzbuzz. They just want to make sure you can string a few lines together.
The ‘default’ form, which most interviewers will expect, is a little ‘ugly’ :
for (int i = 1; i <= 100; i++) {
string str = “”;
if (i % 3 != 0 && i % 5 ) { str = i }
else {
if (i % 3 == 0) { str = str + “Fizz” }
if (i % 5 == 0) { str = str + “Buzz” }
}
fprint(str + “,\n”);
}
This is readable, but it’s really easy to get confused by it, and not just cause I used Egyptian brackets. Indeed, that’s part of the point of the fizzbuzz test, as many inexperienced programmers will get the if-else’s mixed up and thus output fizzfizzbuzzbuzz or nothing on 15s, or run into other problems. Some things that seem like they’d make it cleaner will either break it or make it less accessible Worse, it’ll tweak experienced coder’s expectations of ‘elegance’: unnecessary nested conditionals are Incorrect.
That’s not always bad – there’s a lot of places where inelegant code is the right solution, and here the inelegant solution has the benefit of following the phrasing of the question, and a lot of times making elegant efficient code doesn’t matter. But it’s not necessarily something you want to teach.
You can clean it up a little without changing the toolkit too much :
for (int i = 1; i <= 100; i ++) {
if (i % 15 == 0) { fprint(”FizzBuzz,\n”) }
elseif (i % 5 == 0) { fprint(”Buzz, \n”); }
elseif (i % 3 == 0) { fprint(”Fizz, \n”); }
else { (fprint(i + ”, \n”); }
}
It’ll still bug the hell out of anyone that’s done optimization work on modern CPUs – the most common situation is tested last, the least-common is tested first, which does have a cost – but you don’t need to optimize a problem of n = 100. The biggest downside is readability : it’s not as obvious from the code what the original question is, and programmers raised in the field of ‘self-documenting code’ will wince a bit. Of course, self-documenting programmers should be fired out of a cannon into the sun, so it all works out. (Some languages support switch/case for this style of answer, which are ‘better-looking’ and usually have programming benefits, but I can’t get tumblr to accept it reasonably.)
You can actually do some clever stuff that makes it look nicer and optimize it better: it’s entirely possible to write FizzBuzz without any branching at all! Of course, if you go too far down those paths you risk the interviewer not recognizing the answer, either.
Thanks for the explanation! I see what you mean now.
An elegant solution: Array.apply(null,Array(100)).map((c, i)=>{return (++i%3?“”:“Fizz”)+(i%5?“”:“Buzz”)||i})
(For bonus points, explain why you have to use Array.apply(null, Array(100)) instead of Array(100).)
holy side effects and typecasts, batman
#include <stdwhiteboard.h>
fizzbuzz(100);
shkreli-for-president is the only right-thinking one here; I’d love to ragequit an interview that expected ifs and elses instead of teh pretty
the only problem is the fucking javascript why is there javascript in my fizzbuzz
jesus
im sorry
how did they get an interview tho
def fizzbuzz(up_to)
(1..up_to).map do |i|
str = “
str << ‘fizz’ if i % 3 == 0
str << 'buzz’ if i % 5 == 0
str.empty? ? i : str
end
endputs fizzbuzz(100)
this is still not perfect because it’s not 100% elegant and it’s in Ruby instead of Rust or Haskell or something but at least it’s not Javascript and it represents what I’d actually do in a fizzbuzz interview if I had to do one now; if I wanted to do it more Properly I’d make a generic modulo matcher function and then define fizzbuzz as taking a specific form of it (no I hand’t read this one when I was writing that)
and troll answers:
- code a RNN and train it with 50 000 iterations of random parts of the input until it correctly outputs fizzbuzz
- note that fizzbuzz is a common problem and write it into a library anyone can use and push onto github and your programming language’s package manager (it has one, right?) and package it for AUR
- send it to amazon mechanical turk, because paying them to write the answers manually is cheaper than your hourly wages
1 week ago · tagged #baby leet · 63 notes · source: nniihilsupernum · .permalink
ozymandias271 liked this
radicaleidoscope liked this
infodump-playhouse reblogged this from socialjusticemunchkin
autismserenity liked this
zeteticelench liked this
ilzolende liked this
kaynank liked this
not-a-lizard liked this
nuclearspaceheater reblogged this from theinternetcrab and added:#include fizzbuzz(100);
rangi42 liked this
shacklesburst liked this
obiternihili liked this
theinternetcrab reblogged this from shkreli-for-president and added:holy side effects and typecasts, batman
team-yume liked this
shkreli-for-president reblogged this from another-normal-anomaly and added:An elegant solution: Array.apply(null,Array(100)).map((c, i)=>{return (++i%3?“”:“Fizz”)+(i%5?“”:“Buzz”)||i})(For bonus...
maddeningscientist liked this
another-normal-anomaly reblogged this from gattsuru and added:Thanks for the explanation! I see what you mean now.
andaisq liked this
molibdenita liked this
nostalgebraist liked this
gattsuru reblogged this from another-normal-anomaly and added:The ‘default’ form, which most interviewers will expect, is a little ‘ugly’ : for (int i = 1; i
kelsbraintumbler liked this
mitoticcephalopod reblogged this from shitifindon
shitifindon reblogged this from plain-dealing-villain and added:…my soul hurts.
hatefollows liked this
mugasofer reblogged this from goddygaudess and added:based on a children’s game
isabelknight liked this
nentuaby reblogged this from shitifindon and added:http://c2.com/cgi/wiki?FizzBuzzTest
goddygaudess reblogged this from shitifindon and added:I hated fizzbuzz of course I wanted it to look nice instead of being all the ifs and elses! and I could’ve done it if...
plain-dealing-villain reblogged this from shitifindon and added:Write a program that prints the numbers from 1 to 100, but replace every number divisible by 3 with “fizz” and every...
speakertoyesterday said: c2.com/cgi/wik…
speakertoyesterday reblogged this from nniihilsupernum and added:Interviews are way more stressful then working on things would be. There is a reason Matasano security doesn’t do them...
rocketgarden91 reblogged this from nniihilsupernum and added:The elegance thing is actually a huge hangup. The first time I heard about fizzbuzz (not in an interview, thankfully), I...
nightpool said: i’m pretty sure that 1 in 3 number isn’t actually right for a lot of places also
shuffling-blogs liked this
shedoesnotcomprehend liked this
nniihilsupernum reblogged this from woodswordsquire and added:i mean, fizzbuzz is really easy, people who can fail to do it bc of performance anxiety should probably not have...
arbitrarilychosen liked this
78nanosieverts liked this
woodswordsquire reblogged this from nniihilsupernum and added:I always wonder how many failures to fizzbuzz are more about performance anxiety than lack of skill.
acertainaccountofevents said: One’s ability to do stuff in typical live coding interviews settings is also not necessarily the same as one’s ability to do things in less stressful/unfamiliar situation.- Show more notes