Skip to content

gilmijar/fizzbuzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

fizzbuzz

The not-so-boring solution to the FizzBuzz puzzle.

As the FizzBuzz rules call for starting from 1, we can mentally translate the divisibility requirements to nth multiple requrement, e.g. "every number divisible by 3" becomes "every 3rd number"
We divide the nth-expression generation into 3 responsibility tiers. the "3-multiple" Fizz tier, the "5-multiple" Buzz tier and the "15-multiple" FizzBuzz tier. We create 3 generators, one for each tier.
The first generator keeps track if integers (or the index of the FizzBuzz expression form the start) and returns (technically yields) either the number or the word "fizz", according to rules.
The other tiers yield either the previous tier's value, or their assigned word: "buzz" and "fizzbuzz", respectively.

This way we have some fun with generators and we circumvent the need for modulo operations.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages