Easy版题目:
Fizz Buzz
The aim of this test is to implement the FizzBuzz problem.
FizzBuzz is defined for the "natural numbers" (numbers greater than zero) as: - When divisible by 3, you should return "Fizz".
- When divisible by 5, you should return "Buzz".
- When divisible by both 3 and 5, you should return "FizzBuzz".
- When divisible by neither, you should return the number itself.
Hard版题目:
Inverse Fizz Buzz
This is a lot more complicated than the fizzbuzz problem, and takes some real thinking to get right.
The aim of the test is to discover the shortest sequence of consecutive numbers, which when they are run through the fizzbuzz algorithm produce the required output.
For example, the shortest sequence that produces fizz is 3
When looking for the shortest sequence for
fizz buzz
one sequence that produces that output is
3, 4, 5
However, this isn't the shortest. The shortest sequence is 9, 10
In our case, we are only interested in the numbers between 1 and 100, so be sure you limit your calculations to that range, otherwise you are likely to exceed timeout limits.
参考回复可见,发表你的看法比对一下:
|