3 ms·
Yes, that works. But I don't understand the goal of these variant question. The original goal was to weed out obviously incompetent programmers. I accept that
by dalke 11y ago
Yes, that works. But I don't understand the goal of these variant question.
The original goal was to weed out obviously incompetent programmers. I accept that for some positions that's reasonable. But if I were given that question, and end up implementing my own modulo function to replace the missing operator, is that a mark against the interviewee, compared to someone with otherwise identical qualifications who implements your solution? Or someone who does this sieve solution:
def fizzbuzz(n):
n += 1
values = ["%d"]*(n+1)
for i in range(0, n, 3): values[i] = "%d Fizz"
for i in range(0, n, 5): values[i] = "%d Buzz"
for i in range(0, n, 15): values[i] = "%d FizzBuzz"
for i in range(1, n): print values[i]%i
All of these have different performance/memory/maintenance characteristics, but the full constraints are unspecified. At some point it feels like the interviewer just wants to see the monkey dance, by throwing in non-realistic constraints.