Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 2.17 KB

README.md

File metadata and controls

69 lines (47 loc) · 2.17 KB

Context

Imagine the scene. You are eleven years old, and in the five minutes before the end of the lesson, your Maths teacher decides he should make his class more "fun" by introducing a "game".

He explains that he is going to point at each pupil in turn and ask them to say the next number in sequence, starting from one. The "fun" part is that if the number is divisible by three, you instead say "Fizz" and if it is divisible by five you say "Buzz".

So now your maths teacher is pointing at all of your classmates in turn, and they happily shout "one!", "two!", "Fizz!", "four!", "Buzz!"... until he very deliberately points at you, fixing you with a steely gaze... time stands still, your mouth dries up, your palms become sweatier and sweatier until you finally manage to croak "Fizz!". Doom is avoided, and the pointing finger moves on.

So of course in order to avoid embarrassment in front of your whole class, you have to get the full list printed out so you know what to say. Your class has about 33 pupils and he might go round three times before the bell rings for break time. Next maths lesson is on Thursday. Get coding!

Goal

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

#Sample output

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
... etc up to 100

Stop reading until you have developed this part


New requirements

  • A number is Fizz if it has a 3 in it

  • A number is Buzz if it has a 5 in it

  • A number is FizzBuzz if

    • it has a 3 in it
    • it has a 5 in it
  • The previous requirements are still correct.

SOLUTION

Using hypothesis https://hypothesis.readthedocs.io/en/latest/index.html

This solution allow number greater than 100

Configured to run each test with 1000 numbers

5 tests passed in 22 seconds, max_examples=1000 5 tests passed in 260 seconds, max_examples=10000

NOTE: assume() filters the generated test by a conditions

Uncomment verbosity setting in conftest to see all tested numbers