Coder Social home page Coder Social logo

super_fizz_buzz's Introduction

SuperFizzBuzz

In this assignment you'll implement an algorithm that is actually used in some programmer interviews. And the really shocking part is that some people fail it! This is an extension of the FizzBuzz problem, SuperFizzBuzz.

A number has a corresponding output. The rules for determining the output are as follows:

  • If it's evenly divisible by 3, 5, and 7 the output is SuperFizzBuzz
  • If it's evenly divisible by 3 and 7 the output is SuperFizz
  • If it's evenly divisible by 5 and 7 the output is SuperBuzz
  • If it's evenly divisible by 3 and 5 the output is FizzBuzz
  • If it's evenly divisible by 3, the output is Fizz
  • If it's evenly divisible by 5, the output is Buzz
  • If it's evenly divisible by 7, the output is Super
  • Otherwise the output is just the number

Iteration 1

Write a program called super_fizz_buzz.rb. This program should iterate through the numbers 1 to 1000 and for each one, print the output according to the rules above. The output of your program should look something like this:

1
2
Fizz
4
Buzz
Fizz
Super
8
Fizz
Buzz
11
Fizz
13
Super
FizzBuzz
16
...

Iteration 2

Refactor your super_fizz_buzz.rb file into a class. You should be able to interact with your class from a pry session like so:

require './super_fizz_buzz'

super_fizz = SuperFizzBuzz.new

super_fizz.output(8)
# => "8"

super_fizz.output(15)
# => "FizzBuzz"

super_fizz.output_range(8, 15)
# => ["8", "Fizz", "Buzz", "11", "Fizz", "13", "Super", "FizzBuzz"]

Iteration 3

Write RSpec tests to verify the behavior of your class. Each method should have at least one test.

Iteration 4

Create a command line interface where the user can enter a number or a range of numbers and see the output. Example:

Welcome to SuperFizzBuzz! Enter a number or a range...

# => 15
SuperFizzBuzz

#=> 8, 15
8, Fizz, Buzz, 11, Fizz, 13, Super, FizzBuzz

super_fizz_buzz's People

Contributors

cjsim89 avatar brianzanti avatar megstang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.