3 ms·
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 overwr
by wrsh07 10y ago
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.
- alimw 10y agoThat's exactly how I'd do it! What's supposed to be the better way? Modulo/division by three and five?
- curiousgal 10y ago>Modulo/division by three and five? And fifteen.
- jedberg 10y agofor 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 ""
- _betty_ 10y agofor(var i = 1; i <= 100; i++) { a[fizz +=3] = "fizz" + (a[fizz] || ""); a[buzz +=5] = "buzz"; print(a[i] || i); }