Skip to content

Commit

Permalink
Kata FizzBuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
alex952 authored and 12meses12katas committed Apr 25, 2011
1 parent acefe56 commit 413e89a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
25 changes: 25 additions & 0 deletions alex952/fizzBuzz.rb
@@ -0,0 +1,25 @@
class FizzBuzz

def Count
(1..100).each do |n|
if n%3 == 0 and n%5 == 0 then
puts "FizzBuzz"
elsif isSomething?(n,3) then
puts "Fizz"
elsif isSomething?(n,5) then
puts "Buzz"
else
puts "#{n}"
end
end
end

def isSomething? (n, mod)
if n%mod == 0 then
return true if n.to_s =~ /#{mod.to_s}/
end

return false
end

end
11 changes: 11 additions & 0 deletions alex952/tc_fizzBuzz.rb
@@ -0,0 +1,11 @@
require 'test/unit'
require './fizzBuzz'

class TestFizzBuzz < Test::Unit::TestCase

def setup
@fb = FizzBuzz.new
end

end

0 comments on commit 413e89a

Please sign in to comment.