3 ms·
Was this the expected answer to the coding interview question at places like Renaissance Technologies, Jane Street Capital, and Galois? This is really funny. I
by motohagiography 6y ago
Was this the expected answer to the coding interview question at places like Renaissance Technologies, Jane Street Capital, and Galois?
This is really funny. I had an intuition there must be a lambda function solution for fizzbuzz, but I don't do coding interviews and never pursued it. I can see why now, because it's waaay out of my skillset, but so neat to read.
- leblancfg 6y agoThe lambda's purpose here is only to turn it into a one-liner. It can be rewritten as def fizzbuzz(n): num_map = { 1: n, 6: "Fizz", 10: "Buzz", 0: "FizzBuzz" } return num_map[n**4%15] for i in range(100): print(fizzbuzz(i + 1)) The real skill would be to demonstrate that you know/remember/can apply Euler's totient theorem off-the-cuff in an interview!
- omaranto 6y agoI don't know about Jane Street or Galois, but Renaissance is full of mathematicians so I doubt they'd be impressed by Euler's theorem. Math students learn it in undergrad, it is considered basic.
- roelschroeven 6y agoWe can even easily write it as a one-line without lambda: [{ 1: n, 6: "Fizz", 10: "Buzz", 0: "FizzBuzz" }[n**4%15] for n in range(1, 101)] The lambda in the original code is just used to convert the 0..99 that's generated by range(100) to 1..100. Using range(1, 101) instead generates the appropriate range of numbers from the beginning.
- raverbashing 6y agoYeah if I get asked fizzbuzz at an interview I'll really think less of the interviewer and will try to propose a solution like that ;)
- bidirectional 6y agoJane Street maybe. I've not heard of Galois having a tricky interview process. From what I've heard of Renaissance, this would be insultingly trivial to ask.