Fizz Buzz in Tensorflow(joelgrus.com) |
Fizz Buzz in Tensorflow(joelgrus.com) |
For someone who is truly a senior programmer, they knock it out in about 30 seconds and we move on. For the ones who pretend to be senior programmers on their resume, it trips them up and I know right away that their resume is either a pack of lies or their previous coworkers were helping them a lot more than they let on.
If I had actually had this person, I would have probably laughed as soon as he did the imports, said, "clearly you think this is a silly question" and then explained why I ask that question. Hopefully we could have moved on from there.
Shouldn't a junior programmer be able to solve fizzbuzz?
I'm light years away from being senior, but I can write functions like fizzbuzz in 10 seconds and can't find a junior job
Yes, which is why when I would ask it of a someone who calls themselves a senior programmer I was dumbfounded at how many could not answer the question.
Fine, I accept that there's performance anxiety in interview situations, but if I'm trying out for the Broncos I can't blame it nervousness that I couldn't kick the ball.
haha
It reminds of the paper where they use SVM to "visually identify" the matrix rank:
Joke aside, it's funny how simple machine learning problems can reveal people who think you can just give neural networks anything and output anything, and it will work like magic.
What _is_ the proper method?
- RNN with LSTM might be a better approach, since it will more based on the value of the ordered bits than their "disposition", and could scale to an arbitrary high number.
- @zardo mentioned Pointer Network (https://arxiv.org/abs/1506.03134). It looks to solve this kind of problems but honestly I'm discovering it now.
- Give the base 3 and 5 of the input would be the fastest solution. (but since it's kind of hardcoding part of the solution, it's more a trick than a general solution).
Can anyone correct me what if I got something wrong here? Did I missed something?
If a (senior) developer balks at writing FizzBuzz, perhaps it shows arrogance and a lack of humility. It could also be useful to see if the developer follows up to inquire as to why they were asked a FizzBuzz question, and about its relevance to the work. I see this kind of questioning as not only fair game, but good to ask about. Not asking about something that seems out of place could seem off.
Perfectly learnable to add them all up with the right weights? Given we're doing mod N, negative weights fit in naturally. So, pretty good seems plausible.
Fizz Buzz in combinatory logic, that would be quite entertaining.
>>> for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i
The above line cost your interview :) He might be expecting like this oneI suspect somewhere Hofstadter is having a good laugh.
if i % 15 == 0: return np.array([0, 0, 0, 1])
elif i % 5 == 0: return np.array([0, 0, 1, 0])
elif i % 3 == 0: return np.array([0, 1, 0, 0])
else: return np.array([1, 0, 0, 0])It isn't? I've turned down a couple of sweet gigs, at times when I really needed the comfort of work-group structure and maybe even a pay check, because I assumed that (based on my reading) it was all like that. I knew from history, back in the days when it was called Oak that it was a pretty delightful language. Then WS-* and Enterprise OO happened, and I assumed that's where it all went...
It's a shame that the name "Java" has become synonymous with it, since it really isn't a bad language (as of Java 7, at least).
Don't forget to use a validation set for the model and hyperparameter selection though!
As with many models, I suspect that this network really learned some other property that has almost-but-not-quite the same pattern as divisible-by-N.
But for FizzBuzz I explain the problem, explain that there is no trick and the simplest answer that produces the correct output will be fine. To solve it you need to know about building a loop, what the mod operator does, and maybe keeping state depending on how you build it. I tell them to write it in the language they know best. None of those things should be "gotchas" in your favorite language.
local remove = table.remove
local insert = table.insert
local print = print
local sequence = {
false , false , 'Fizz' , false , 'Buzz',
'Fizz' , false , false , 'Fizz' , 'Buzz' ,
false , 'Fizz' , false , false , 'FizzBuzz'
}
local function o(v)
local name = remove(sequence,1)
insert(sequence,name)
print(name or v)
return v + 1
end
local function t(v)
return o(o(o(o(o(o(o(o(o(o(v))))))))))
end
local function h(v)
t(t(t(t(t(t(t(t(t(t(v))))))))))
end
h(1)
It does rely upon state (the sequence table) but even that could probably be worked around if Lua had a slice syntax.Because it was an unconventional solution, the interviewer didn't like it.
Wie waere es fuer dich, wenn ich in einer Sprache antworte, die du wahrscheinlich nicht verstehst?
[1] https://en.wikipedia.org/wiki/Universal_approximation_theore...
for x in xrange(1,101):
if not x % 3:
print "Fizz",
if not x % 5:
print "Buzz",
if (x % 3) and (x % 5):
print x
else:
print ""And fifteen.
for(var i = 1; i <= 100; i++) {
a[fizz +=3] = "fizz" + (a[fizz] || "");
a[buzz +=5] = "buzz";
print(a[i] || i);
}Although we could debate that the way you call o and t is just you manually expanding a loop. In which case I would question why you didn't just use a loop. :)
I could also debate with you that you had to at least understand what mod is to build the sequence.
I would also give you bonus points for detecting that it is a repeating pattern.
But the point is, you solved it, you wrote code that could solve it. So now I know that you're at least capable of writing basic code, and we've got a couple of things to talk about!
I head the "what if they do it this other weird way?" question off by giving them a simple problem, having them solve it (or at least convince me their solution solves it), and then asking them to solve it a different way. My screens mostly follow the ideas from https://sites.google.com/site/steveyegge2/five-essential-pho... I allocate about 10 minutes max for "basic coding" where I just ask them (lately) to write a function that returns true if the given input int (which is assumed to be > 0) is even and false if odd. Then I ask them to do it in different ways. If they use bit-and, I figure they know enough about the "bits and bytes" section too for my team's purposes. Last time someone couldn't recall using bit-and but surprised me with a way I didn't consider, which was convert to string and check the last character. I'm sure there are other ways to do it I haven't considered either. Maybe someone will give me a solution with tensorflow someday, but what would be really impressive is if they bust that out within a few minutes. :) All I'm really after is "can you write code?", if the answer is no then very little time was wasted, if the answer was yes we can go into variations and other questions to rank the other yeses / find other red flags.
Console.Write(String.Join("\r\n", Enumerable.Range(1, 100).Select(x => x % 15 == 0 ? "FizzBuzz" : x % 5 == 0 ? "Buzz" : x % 3 == 0 ? "Fizz" : x.ToString()))); Array.from(Array(100).keys()).map(k => k + 1).map(i => !(i % 15) && 'fizbizz' || !(i % 5) && 'buzz' || !(i % 3) && 'fizz' || i) Array.from(Array(100).keys()).map(k => k + 1).map(i => [i,'Fizz','Buzz','FizzBuzz'][!(i%3)+2*!(i%5)])