News for hackers. Stuff that matters.
Re:Fizz Buzz in Tensorflow by jedberg on Monday May 23, 2016 @06:55PM (#11757676)
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 of those things should be "gotchas" in your favorite language.

Re:Fizz Buzz in Tensorflow by spc476 on Monday May 23, 2016 @07:24PM (#11757800)
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)
      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.
Re:Fizz Buzz in Tensorflow by jedberg on Monday May 23, 2016 @07:38PM (#11757860)
You're right, it doesn't (clever solution BTW).

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!

Re:Fizz Buzz in Tensorflow by xyience on Monday May 23, 2016 @08:10PM (#11757983)
My team isn't exactly doing "top-tier CS work", so if someone "showed off" how far above the average they are with a Coq solution or the quirky GP you replied to or the OP's neural net I'd be delighted and want to skip the rest of the interview, recommending an immediate hire (or at least a go-to-next-stage since I only give these questions over phone screens). The question is beneath them and they have demonstrated that, our team's work is also probably beneath them. We just use that question to filter out the totally unqualified. Their potential value is high because they are overqualified -- they didn't just pass it, they passed it with style. Most dev work at large companies is dull and doesn't require much knowledge that e.g. a CS degree supposedly gives, which is part of why it's amusing/frustrating we have such a bad whiteboard hazing culture insisting candidates can invert a tree or whatever.

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.

Re:Fizz Buzz in Tensorflow by Pharylon on Monday May 23, 2016 @08:41PM (#11758123)
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 by spc476 on Monday May 23, 2016 @09:59PM (#11758486)
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 by davidy123 on Monday May 23, 2016 @11:01PM (#11758716)
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)
Re:Fizz Buzz in Tensorflow by ingenter on Tuesday May 24, 2016 @06:20AM (#11760231)
No need for ternaries!

    Array.from(Array(100).keys()).map(k => k + 1).map(i => [i,'Fizz','Buzz','FizzBuzz'][!(i%3)+2*!(i%5)])
Re:Fizz Buzz in Tensorflow by wrsh07 on Tuesday May 24, 2016 @10:24AM (#11761749)
One of my friends failed an interview out of college where they asked him fizz buzz, and [using python] he created an array [list(range(1,101))] and then overwrote multiples of 3 with "fizz" multiples of 5 with "buzz" and multiples of 15 with "fizzbuzz."

Because it was an unconventional solution, the interviewer didn't like it.

Re:Fizz Buzz in Tensorflow by alimw on Tuesday May 24, 2016 @12:26PM (#11762886)
That's exactly how I'd do it! What's supposed to be the better way? Modulo/division by three and five?
Re:Fizz Buzz in Tensorflow by jedberg on Thursday May 26, 2016 @01:47AM (#11775820)

    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 ""
Re:Fizz Buzz in Tensorflow by curiousgal on Wednesday May 25, 2016 @05:08AM (#11768545)
>Modulo/division by three and five?

And fifteen.

Re:Fizz Buzz in Tensorflow by _betty_ on Wednesday May 25, 2016 @04:39AM (#11768450)

  for(var i = 1; i <= 100; i++) {
    a[fizz +=3] = "fizz" + (a[fizz] || "");
    a[buzz +=5] = "buzz";
    print(a[i] || i);
  }