Live data from Hacker News

Fizz Buzz in Tensorflow

joelgrus.com

51–60 of 85 posts

Re: Fizz Buzz in Tensorflow

#51
post #40
post #38

Earlier quoted context omitted.

I hate puzzles too, especially the gotcha ones with esoteric knowledge required. 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 o…

You don't need mod, loops or recursion to solve it. For instance: 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) r…

No loops, no sequence, one horrific line. :)

    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())));

Re: Fizz Buzz in Tensorflow

#52
It's a fun article, but solving the problem with the simplest, clearest solution possible should be the goal and if someone provided this solution I would hesitate to hire them. Yak shaving in training a neural network would actually make me nervous that the candidate would over-engineer solutions. It's not like whiteboarding sleep sort or something for a fast easy clever solution (if impractical and inefficient). The guy who has to maintain this version of fizzbuzz after it's wrote would loose his mind. I'm probably being overly practical - it's a very fun article.

Re: Fizz Buzz in Tensorflow

#53

Maybe the one-hot binary encoding wasn't the best feature set. Base 3 and Base 5 encodings might have worked better.

Stupid question: We are trying to train the network how to calculate modulus of division. Of a binary encoding. Why should we expect this to be learnable in only two layers?

The bit string representation actually isn't that bad for modulo computations: 2^n mod 3 is just 1 + (n % 2), and 2^n mod 5 is just {1,2,4,3}[n % 4].

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.

Re: Fizz Buzz in Tensorflow

#54
post #22
post #5

This whole thing is making fun of asking fizz-buzz to a senior programmer, but yet I've found it to be one of the best phone screen questions possible. 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 c…

Senior programmer? ... 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

Last year I interviewed about 5 or 6 senior developers for a .Net role. All took 10 or more minutes to complete the fizzbuzz exercise. One couldn't remember the modulo operator. One of the fastest candidates handed me his solution and it didn't compile (this guy's CV also had all of the latest and greatest frameworks listed in his experience).

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.

Re: Fizz Buzz in Tensorflow

#55

It's a fun article, but solving the problem with the simplest, clearest solution possible should be the goal and if someone provided this solution I would hesitate to hire them. Yak shaving in training a neural network would actually make me nervous that the candidate would over-engineer solutions. It's not like whiteboarding sleep sort or something for a fast easy clever solution (if impractical and inefficient). Th…

Lighten up

Re: Fizz Buzz in Tensorflow

#56
Seems like a bit of a wasted opportunity to assume input as binary digits, rather than as a sequence of hand-written numbers on the white-board. Then there should of course be a second whiteboard, and a robot arm with a marker for output, along with a pair of cameras for stereo input and feedback while training the robot arm in hand-writing "fizz", "buzz" and "fizzbuzz" ...

Re: Fizz Buzz in Tensorflow

#57
post #40

Earlier quoted context omitted.

You don't need mod, loops or recursion to solve it. For instance: 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) r…

No loops, no sequence, one horrific line. :) 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())));

There's a hidden loop in Enumerable.Range(), and quite possibly another one in String.Join(). Just because you avoided an explicit loop doesn't mean there isn't one (for example, an "if" statements has an implicit GOTO).

Re: Fizz Buzz in Tensorflow

#58

Earlier quoted context omitted.

> what if someone provided Fizz Buzz in COQ or Elixir Wie waere es fuer dich, wenn ich in einer Sprache antworte, die du wahrscheinlich nicht verstehst?

Zavisi. Ako si mi rekao da mogu da koristim bilo koji jezik, onda je na tebi da pronađeš prevod ;)

Au secours! J'ai compris une-et-demi de ces réponses. Време ли е за Физз-Бузз?

Re: Fizz Buzz in Tensorflow

#60
post #40

Earlier quoted context omitted.

You don't need mod, loops or recursion to solve it. For instance: 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) r…

No loops, no sequence, one horrific line. :) 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())));

Ternaries aren't super readable.

  Array.from(Array(100).keys()).map(k => k + 1).map(i => !(i % 15) && 'fizbizz' || !(i % 5) && 'buzz' || !(i % 3) && 'fizz' || i)
Post reply on HN