FizzBuzz, but with no ifs
FizzBuzz is a classic interview exercise meant to filter out people who can't program. It tests that you can write conditionals, loops, and a basic modulo check for divisibility. While it seems kind of insulting to ask someone to solve such a trivial problem, imagine if the interviewee couldn't do it. It's a quick way to check for basic skill before wasting an hour in the interview.
This week, you're going to write FizzBuzz, but just to show off to the interviewer, you're not going to write any conditionals or loops. Just to be clear, that means no if
, when
, cond
, or case
expressions.
Here are the rules:
Write a function that is passed a sequence of integers.
For each integer, if it's divisible by 3, print "Fizz". If it's divisible by 5, print "Buzz". If it's divisible by both 3 and 5, print "FizzBuzz". Finally, if it's divisible by neither, print the number itself. Each printing should be on a separate line.
Email submissions to eric@purelyfunctional.tv before September 13, 2020. You can discuss the submissions in the comments below.
Replacing
doseq
withmap
: