FizzBuzz is a classic programming exercise (and fairly common interview question); here is my rendition with benchmarking!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
BenchmarkOutput.txt
benchmark.rb
fizz_buzz_spec.rb
fizzbuzz.rb
my_solution_
mysolution_ExtendedCommentaryEdition.rb.rb
readme.md
refactor_attempts.rb

readme.md

#FizzBuzz

Implementing FizzBuzz (Super Edition)

Learning Competencies

  • Use strings, integers, arrays, and hashes
  • Use if/else statements, string methods, while/until loops, Enumerable#each methods
  • Translate driver test code into assert statements

Summary:

FizzBuzz is a classic programming exercise (and fairly common interview question).

The usual example asks the developer to write a program which prints out each number from 1 to 100. But for multiples of 3 print 'Fizz' instead of the number and for multiples of 5 print 'Buzz'. For numbers which are multiples of both 3 and 5 print 'FizzBuzz'.

This exercise has a little twist. Write a method called super_fizzbuzz which takes as its input an Array of integers.

It should return a "fizzbuzzed" Array, i.e., the array is identical to the input with the following substitutions:

  1. Multiples of 3 should be replaced with the string "Fizz"
  2. Multiples of 5 should be replaced with the string "Buzz"
  3. Multiples of 15 should be replaced with the string "FizzBuzz"

For example:

```ruby
super_fizzbuzz([1,2,3])  # => [1, 2, "Fizz"]
super_fizzbuzz([1,2,5])  # => [1, 2, "Buzz"]
super_fizzbuzz([1,2,15]) # => [1, 2, "FizzBuzz"]

super_fizzbuzz([30, 9, 20, 1]) # => ["FizzBuzz", "Fizz", "Buzz", 1]

Release 0: Run the Tests

Release 1: Translate Rspec

Translate Rspec into Assert Statements or Driver Test Code

Release 2: Write Pseudocode

Release 3: Write your initial solution

Release 4: Refactor

Release 5: Reflect

Please review my blog post for academic analysis. Thanks!

Release 6: Review