4 ms·
FWIW my FizzBuzz solution involves no 'for' loops, and in fact involves no control-flow keywords at all.
by ubernostrum 9y ago
FWIW my FizzBuzz solution involves no 'for' loops, and in fact involves no control-flow keywords at all.
- monocasa 9y agoHaha, I'd love to see it if that's true. I love cool approaches to computation. FWIW as long as you can back it up with knowledge of what the relevant tradeoffs are (and don't scoff at a more KISS attitude for doing actual work), you're pretty much guaranteed to get a thumbs up from me if you give an answer off the beaten path.
- ubernostrum 9y agoI dislike traditional phone screens enough that I hone unusual solutions for them. And when they get evil enough, I put them in a public repository. Here's my FizzBuzz: https://github.com/ubernostrum/interviewer-hell/blob/master/fizzbuzz/iterator.py https://github.com/ubernostrum/interviewer-hell/blob/master/...
- monocasa 9y agoThat's awesome! I'd probably follow up that, since I generally interview for real time, firmware jobs, we try to clearly bound execution time, and therefore frown against more functional techniques like that. But you clearly know how to program well and would most likely get a thumbs up. : )
- deleted 9y ago[deleted]
- ubernostrum 9y agoAdmittedly most of my phone-screen solutions aren't tuned for performance; they're tuned to make people scratch their heads. My code for "detect if a number is a perfect square", though, is O(sqrt(n)) time and O(1) space and uses no floating point operations. Which isn't quite Newton's method, but also saves me having to memorize an implementation of Newton's method and appropriately causes confusion. Here it is in Python, with obfuscation help from itertools: https://github.com/ubernostrum/interviewer-hell/blob/master/squares/odds.py https://github.com/ubernostrum/interviewer-hell/blob/master/... And slightly less obfuscated C: https://github.com/ubernostrum/interviewer-hell/blob/master/squares/odds.c https://github.com/ubernostrum/interviewer-hell/blob/master/...
- bendtherules 8y agoHow is that not iterating (admittedly within the stdlib methods)? They are not literally for loops, but the same concept of iteration.