class Fixnum
def <=>(b)
self % b
end
def fizz?
self % 3 == 0
end
def buzz?
self % 5 == 0
end
end
(1..100).each do |number|
if number.fizz?
if number.buzz?
puts 'FizzBuzz'
else
puts 'Fizz'
end
else
puts 'Buzz'
end
end
Refactorings
No refactoring yet !
danielharan
December 20, 2007, December 20, 2007 22:18, permalink
I was inspired by http://refactormycode.com/codes/102-i-hate-to-do-this-but
I'm sure someone can figure something better than mine, but I thought proper namespacing was important. To keep the line count from going up too high, I used a few ternary operators. Also, that each is quite confusing so used a loop instead.
module Wasabi
module Fizzy
def fizzy?
self % 3 == 0
end
end
module Buzzy
def buzzy?
self % 5 == 0
end
end
module SpaceCadet
def <=>(b)
self % b
end
end
end
class Fixnum
include Wasabi::Fizzy
include Wasabi::Buzzy
include Wasabi::SpaceCadet
end
number = 0
while number < 101 do
number += 1
puts number.fizzy? ? number.buzzy? ? 'FizzBuzz' : 'Fizz' : number.buzzy? ? 'Buzz' : number.to_s
end
Gary Haran
December 20, 2007, December 20, 2007 22:23, permalink
Mine runs faster than yours
puts '1' puts '2' puts 'buzz' puts '4' puts 'fizz' puts 'buzz' puts '7' puts '8' puts 'buzz' puts 'fizz' puts '11' puts 'buzz' puts '13' puts '14' puts 'fizzbuzz' puts '16' puts '17' puts 'buzz' puts '19' puts 'fizz' puts 'buzz' puts '22' puts '23' puts 'buzz' puts 'fizz' puts '26' puts 'buzz' puts '28' puts '29' puts 'fizzbuzz' puts '31' puts '32' puts 'buzz' puts '34' puts 'fizz' puts 'buzz' puts '37' puts '38' puts 'buzz' puts 'fizz' puts '41' puts 'buzz' puts '43' puts '44' puts 'fizzbuzz' puts '46' puts '47' puts 'buzz' puts '49' puts 'fizz' puts 'buzz' puts '52' puts '53' puts 'buzz' puts 'fizz' puts '56' puts 'buzz' puts '58' puts '59' puts 'fizzbuzz' puts '61' puts '62' puts 'buzz' puts '64' puts 'fizz' puts 'buzz' puts '67' puts '68' puts 'buzz' puts 'fizz' puts '71' puts 'buzz' puts '73' puts '74' puts 'fizzbuzz' puts '76' puts '77' puts 'buzz' puts '79' puts 'fizz' puts 'buzz' puts '82' puts '83' puts 'buzz' puts 'fizz' puts '86' puts 'buzz' puts '88' puts '89' puts 'fizzbuzz' puts '91' puts '92' puts 'buzz' puts '94' puts 'fizz' puts 'buzz' puts '97' puts '98' puts 'buzz' puts 'fizz'
macournoyer
December 20, 2007, December 20, 2007 23:48, permalink
Mine is more rubust
class FizzBuzz
class << self
attr_accessor :_fizzbuzz_trans_keys
end
self._fizzbuzz_trans_keys = [
0, 0, 10, 57, 10, 57,
10, 57, 10, 57, 10,
57, 10, 57, 10, 57,
10, 57, 10, 57, 10, 57,
10, 57, 10, 57, 10,
57, 10, 57, 10, 57,
10, 57, 0
]
class << self
attr_accessor :_fizzbuzz_key_spans
end
self._fizzbuzz_key_spans = [
0, 48, 48, 48, 48, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48,
48
]
class << self
attr_accessor :_fizzbuzz_index_offsets
end
self._fizzbuzz_index_offsets = [
0, 0, 49, 98, 147, 196, 245, 294,
343, 392, 441, 490, 539, 588, 637, 686,
735
]
class << self
attr_accessor :_fizzbuzz_indicies
end
self._fizzbuzz_indicies = [
0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 3,
4, 5, 6, 7, 5, 6, 4, 5,
1, 8, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 9,
10, 11, 12, 13, 14, 12, 13, 11,
12, 1, 15, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
16, 17, 18, 19, 20, 21, 19, 20,
18, 19, 1, 8, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 22, 10, 23, 12, 13, 24, 12,
13, 23, 12, 1, 25, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 26, 27, 28, 29, 30, 31,
29, 30, 28, 29, 1, 25, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 32, 27, 28, 29, 30,
31, 29, 30, 28, 29, 1, 8, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 33, 34, 11, 12,
35, 14, 12, 35, 11, 12, 1, 36,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 37, 38, 39,
40, 41, 42, 40, 41, 39, 40, 1,
36, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 43, 44,
45, 40, 46, 47, 40, 46, 45, 40,
1, 36, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 48,
38, 45, 40, 41, 47, 40, 41, 45,
40, 1, 49, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
50, 51, 52, 53, 54, 55, 53, 54,
52, 53, 1, 8, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 33, 10, 23, 12, 13, 24, 12,
13, 23, 12, 1, 49, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 56, 57, 52, 53, 58, 55,
53, 58, 52, 53, 1, 36, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 43, 38, 39, 40, 41,
42, 40, 41, 39, 40, 1, 25, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 26, 59, 28, 29,
60, 31, 29, 60, 28, 29, 1, 15,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 16, 17, 18,
19, 20, 21, 19, 20, 18, 19, 1,
0
]
class << self
attr_accessor :_fizzbuzz_trans_targs_wi
end
self._fizzbuzz_trans_targs_wi = [
16, 0, 2, 4, 7, 10, 12, 15,
3, 2, 4, 7, 10, 12, 15, 16,
2, 4, 7, 10, 12, 15, 5, 9,
13, 3, 6, 4, 7, 10, 12, 15,
2, 6, 8, 14, 3, 5, 4, 9,
10, 12, 13, 6, 8, 7, 14, 15,
11, 3, 2, 4, 7, 10, 12, 15,
6, 8, 14, 8, 14
]
class << self
attr_accessor :_fizzbuzz_trans_actions_wi
end
self._fizzbuzz_trans_actions_wi = [
1, 0, 2, 2, 2, 2, 2, 2,
0, 0, 0, 0, 0, 0, 0, 3,
4, 4, 4, 4, 4, 4, 0, 0,
0, 5, 5, 5, 5, 5, 5, 5,
5, 0, 0, 0, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 5, 5
]
class << self
attr_accessor :fizzbuzz_start
end
self.fizzbuzz_start = 1;
class << self
attr_accessor :fizzbuzz_first_final
end
self.fizzbuzz_first_final = 16;
class << self
attr_accessor :fizzbuzz_error
end
self.fizzbuzz_error = 0;
class << self
attr_accessor :fizzbuzz_en_main
end
self.fizzbuzz_en_main = 1;
def initialize(data)
@num = 1
@data = data
begin
@p ||= 0
@pe ||= @data.length
@cs = self.class.fizzbuzz_start
end
end
def execute
parser = self
begin # ragel fflat
_slen, _trans, _keys, _inds, _acts, _nacts = nil
if @p != @pe # pe guard
if @cs != 0 # errstate guard
while true # _resume loop
_break_resume = false
begin
_break_again = false
_keys = @cs << 1
_inds = self.class._fizzbuzz_index_offsets[ @cs]
_slen = self.class._fizzbuzz_key_spans[ @cs]
_trans = if ( _slen > 0 &&
self.class._fizzbuzz_trans_keys[_keys] <= @data[ @p] &&
@data[ @p] <= self.class._fizzbuzz_trans_keys[_keys + 1]
) then
self.class._fizzbuzz_indicies[ _inds + @data[ @p] - self.class._fizzbuzz_trans_keys[_keys] ]
else
self.class._fizzbuzz_indicies[ _inds + _slen ]
end
@cs = self.class._fizzbuzz_trans_targs_wi[_trans]
break if self.class._fizzbuzz_trans_actions_wi[_trans] == 0
case self.class._fizzbuzz_trans_actions_wi[_trans]
when 2
begin
@start_num = @p end
when 6
begin
puts 'fizz' end
when 5
begin
puts 'buzz' end
when 1
begin
@start_num = @p end
begin
begin
_break_resume = true
break
end
end
when 4
begin
puts @data[@p, @p - @start_num] end
begin
@start_num = @p end
when 7
begin
puts 'fizz' end
begin
puts 'buzz' end
when 3
begin
puts @data[@p, @p - @start_num] end
begin
@start_num = @p end
begin
begin
_break_resume = true
break
end
end
end # action switch
end while false # _again loop
break if _break_resume
break if @cs == 0
@p += 1
break if @p == @pe
end # _resume loop
end # errstate guard
end # pe guard
end
end
end
if __FILE__ == $PROGRAM_NAME
FizzBuzz.new((0..100).to_a.join("\n") + "\n").execute
end
jamesgolick
December 20, 2007, December 20, 2007 23:55, permalink
oh my... I'd like to see somebody beat that.
Scott Robinson
December 21, 2007, December 21, 2007 02:49, permalink
Oh my God. I don't have enough five stars to give.
danielharan
December 21, 2007, December 21, 2007 15:53, permalink
No way can I compete with MA... for now, I'll just tweak my solution to make it more maintainable. Really, though, shouldn't this be a script where we can give params for start and end? What if requirements change, and we decide divisibility by 13 is fizzbazzy?
def fizz! 'fizz' end def buzz! 'buzz' end def fizzbuzz! fizz! + buzz! end number = 0 while number < 101 do number += 1 puts number.fizzy? ? number.buzzy? ? fizzbuzz! : fizz! : number.buzzy? ? buzz! : number.to_s end
Dennis
December 22, 2007, December 22, 2007 01:27, permalink
Too basic?
rube <<BASIC
let i% = 0
goto loop
3: print "Fizz"
goto loop
five: print "Buzz"
goto loop
15: print "FizzBuzz"
goto loop
loop: set i% = i% + 1
if i% > 100 then goto done
if i% % 15 == 0 then goto 15
if i% % 5 == 0 then goto five
if i% % 3 == 0 then goto 3
print i%
goto loop
done: quit
BASIC
BEGIN {
def rube(program)
env = {}
target = nil
statements = program.split(/\n/).map do |s| # prepare statements
s = s.gsub( /"([^"]+)"/ ) {|x| x.gsub(/\s/, '&space;')}
s.gsub(/^\s+|\s+$/,'').split(/\s+/)
end
pc = 0
words = statements[pc]
while true
if words.length == 0 or (!target.nil? and words[0] != target)
# do nothing
elsif words[0] =~ /:$/ # a label
if words[0] == target or target.nil?
words = words[1..-1] # drop it
target = nil
redo
end
elsif words[0] =~ /^[sl]et/ # assigment
var = words[1]
env_words = words[3..-1].map {|w| (env[w] ? env[w].to_s : w)}
env[var] = eval(env_words.join(" "))
elsif words[0] == 'if' # conditional
condition = []
consequent = []
switch = false
for w in words[1..-1]
if w == 'then' then switch = true
elsif switch then consequent << w
else condition << w end end
env_expr = condition.map {|w| (env[w] or w)}
if eval(env_expr.join(' '))
words = consequent
redo
end
elsif words[0] == 'print' # output
puts words[1] =~ /^"(.+)"/ ? $1.gsub(/&space;/,' ') : env[words[1]]
elsif words[0] == 'goto' # flow control
target = words[1] + ':' ; pc = -1
elsif words[0] == 'quit' then return end
pc = pc + 1
words = statements[pc]
end
end
}
Coda Hale
December 22, 2007, December 22, 2007 02:38, permalink
Rails style. Y'know. To make it more extensible.
require "rubygems"
require "active_support"
class FizzBuzz
attr_reader :number
def initialize(number)
@number = number
end
def fizz?
false
end
def buzz?
false
end
def to_s
@number.to_s
end
end
module FizzBuzz1
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_1 }
base.instance_eval { alias_method_chain :buzz?, :input_1 }
end
def fizz_with_input_1?
if number == 1
return false
else
fizz_without_input_1?
end
end
def buzz_with_input_1?
if number == 1
return false
else
buzz_without_input_1?
end
end
end
module FizzBuzz2
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_2 }
base.instance_eval { alias_method_chain :buzz?, :input_2 }
end
def fizz_with_input_2?
if number == 2
return false
else
fizz_without_input_2?
end
end
def buzz_with_input_2?
if number == 2
return false
else
buzz_without_input_2?
end
end
end
module FizzBuzz3
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_3 }
base.instance_eval { alias_method_chain :buzz?, :input_3 }
end
def fizz_with_input_3?
if number == 3
return true
else
fizz_without_input_3?
end
end
def buzz_with_input_3?
if number == 3
return false
else
buzz_without_input_3?
end
end
end
module FizzBuzz4
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_4 }
base.instance_eval { alias_method_chain :buzz?, :input_4 }
end
def fizz_with_input_4?
if number == 4
return false
else
fizz_without_input_4?
end
end
def buzz_with_input_4?
if number == 4
return false
else
buzz_without_input_4?
end
end
end
module FizzBuzz5
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_5 }
base.instance_eval { alias_method_chain :buzz?, :input_5 }
end
def fizz_with_input_5?
if number == 5
return false
else
fizz_without_input_5?
end
end
def buzz_with_input_5?
if number == 5
return true
else
buzz_without_input_5?
end
end
end
module FizzBuzz6
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_6 }
base.instance_eval { alias_method_chain :buzz?, :input_6 }
end
def fizz_with_input_6?
if number == 6
return true
else
fizz_without_input_6?
end
end
def buzz_with_input_6?
if number == 6
return false
else
buzz_without_input_6?
end
end
end
module FizzBuzz7
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_7 }
base.instance_eval { alias_method_chain :buzz?, :input_7 }
end
def fizz_with_input_7?
if number == 7
return false
else
fizz_without_input_7?
end
end
def buzz_with_input_7?
if number == 7
return false
else
buzz_without_input_7?
end
end
end
module FizzBuzz8
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_8 }
base.instance_eval { alias_method_chain :buzz?, :input_8 }
end
def fizz_with_input_8?
if number == 8
return false
else
fizz_without_input_8?
end
end
def buzz_with_input_8?
if number == 8
return false
else
buzz_without_input_8?
end
end
end
module FizzBuzz9
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_9 }
base.instance_eval { alias_method_chain :buzz?, :input_9 }
end
def fizz_with_input_9?
if number == 9
return true
else
fizz_without_input_9?
end
end
def buzz_with_input_9?
if number == 9
return false
else
buzz_without_input_9?
end
end
end
module FizzBuzz10
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_10 }
base.instance_eval { alias_method_chain :buzz?, :input_10 }
end
def fizz_with_input_10?
if number == 10
return false
else
fizz_without_input_10?
end
end
def buzz_with_input_10?
if number == 10
return true
else
buzz_without_input_10?
end
end
end
module FizzBuzz11
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_11 }
base.instance_eval { alias_method_chain :buzz?, :input_11 }
end
def fizz_with_input_11?
if number == 11
return false
else
fizz_without_input_11?
end
end
def buzz_with_input_11?
if number == 11
return false
else
buzz_without_input_11?
end
end
end
module FizzBuzz12
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_12 }
base.instance_eval { alias_method_chain :buzz?, :input_12 }
end
def fizz_with_input_12?
if number == 12
return true
else
fizz_without_input_12?
end
end
def buzz_with_input_12?
if number == 12
return false
else
buzz_without_input_12?
end
end
end
module FizzBuzz13
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_13 }
base.instance_eval { alias_method_chain :buzz?, :input_13 }
end
def fizz_with_input_13?
if number == 13
return false
else
fizz_without_input_13?
end
end
def buzz_with_input_13?
if number == 13
return false
else
buzz_without_input_13?
end
end
end
module FizzBuzz14
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_14 }
base.instance_eval { alias_method_chain :buzz?, :input_14 }
end
def fizz_with_input_14?
if number == 14
return false
else
fizz_without_input_14?
end
end
def buzz_with_input_14?
if number == 14
return false
else
buzz_without_input_14?
end
end
end
module FizzBuzz15
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_15 }
base.instance_eval { alias_method_chain :buzz?, :input_15 }
end
def fizz_with_input_15?
if number == 15
return true
else
fizz_without_input_15?
end
end
def buzz_with_input_15?
if number == 15
return true
else
buzz_without_input_15?
end
end
end
module FizzBuzz16
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_16 }
base.instance_eval { alias_method_chain :buzz?, :input_16 }
end
def fizz_with_input_16?
if number == 16
return false
else
fizz_without_input_16?
end
end
def buzz_with_input_16?
if number == 16
return false
else
buzz_without_input_16?
end
end
end
module FizzBuzz17
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_17 }
base.instance_eval { alias_method_chain :buzz?, :input_17 }
end
def fizz_with_input_17?
if number == 17
return false
else
fizz_without_input_17?
end
end
def buzz_with_input_17?
if number == 17
return false
else
buzz_without_input_17?
end
end
end
module FizzBuzz18
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_18 }
base.instance_eval { alias_method_chain :buzz?, :input_18 }
end
def fizz_with_input_18?
if number == 18
return true
else
fizz_without_input_18?
end
end
def buzz_with_input_18?
if number == 18
return false
else
buzz_without_input_18?
end
end
end
module FizzBuzz19
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_19 }
base.instance_eval { alias_method_chain :buzz?, :input_19 }
end
def fizz_with_input_19?
if number == 19
return false
else
fizz_without_input_19?
end
end
def buzz_with_input_19?
if number == 19
return false
else
buzz_without_input_19?
end
end
end
module FizzBuzz20
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_20 }
base.instance_eval { alias_method_chain :buzz?, :input_20 }
end
def fizz_with_input_20?
if number == 20
return false
else
fizz_without_input_20?
end
end
def buzz_with_input_20?
if number == 20
return true
else
buzz_without_input_20?
end
end
end
module FizzBuzz21
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_21 }
base.instance_eval { alias_method_chain :buzz?, :input_21 }
end
def fizz_with_input_21?
if number == 21
return true
else
fizz_without_input_21?
end
end
def buzz_with_input_21?
if number == 21
return false
else
buzz_without_input_21?
end
end
end
module FizzBuzz22
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_22 }
base.instance_eval { alias_method_chain :buzz?, :input_22 }
end
def fizz_with_input_22?
if number == 22
return false
else
fizz_without_input_22?
end
end
def buzz_with_input_22?
if number == 22
return false
else
buzz_without_input_22?
end
end
end
module FizzBuzz23
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_23 }
base.instance_eval { alias_method_chain :buzz?, :input_23 }
end
def fizz_with_input_23?
if number == 23
return false
else
fizz_without_input_23?
end
end
def buzz_with_input_23?
if number == 23
return false
else
buzz_without_input_23?
end
end
end
module FizzBuzz24
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_24 }
base.instance_eval { alias_method_chain :buzz?, :input_24 }
end
def fizz_with_input_24?
if number == 24
return true
else
fizz_without_input_24?
end
end
def buzz_with_input_24?
if number == 24
return false
else
buzz_without_input_24?
end
end
end
module FizzBuzz25
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_25 }
base.instance_eval { alias_method_chain :buzz?, :input_25 }
end
def fizz_with_input_25?
if number == 25
return false
else
fizz_without_input_25?
end
end
def buzz_with_input_25?
if number == 25
return true
else
buzz_without_input_25?
end
end
end
module FizzBuzz26
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_26 }
base.instance_eval { alias_method_chain :buzz?, :input_26 }
end
def fizz_with_input_26?
if number == 26
return false
else
fizz_without_input_26?
end
end
def buzz_with_input_26?
if number == 26
return false
else
buzz_without_input_26?
end
end
end
module FizzBuzz27
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_27 }
base.instance_eval { alias_method_chain :buzz?, :input_27 }
end
def fizz_with_input_27?
if number == 27
return true
else
fizz_without_input_27?
end
end
def buzz_with_input_27?
if number == 27
return false
else
buzz_without_input_27?
end
end
end
module FizzBuzz28
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_28 }
base.instance_eval { alias_method_chain :buzz?, :input_28 }
end
def fizz_with_input_28?
if number == 28
return false
else
fizz_without_input_28?
end
end
def buzz_with_input_28?
if number == 28
return false
else
buzz_without_input_28?
end
end
end
module FizzBuzz29
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_29 }
base.instance_eval { alias_method_chain :buzz?, :input_29 }
end
def fizz_with_input_29?
if number == 29
return false
else
fizz_without_input_29?
end
end
def buzz_with_input_29?
if number == 29
return false
else
buzz_without_input_29?
end
end
end
module FizzBuzz30
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_30 }
base.instance_eval { alias_method_chain :buzz?, :input_30 }
end
def fizz_with_input_30?
if number == 30
return true
else
fizz_without_input_30?
end
end
def buzz_with_input_30?
if number == 30
return true
else
buzz_without_input_30?
end
end
end
module FizzBuzz31
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_31 }
base.instance_eval { alias_method_chain :buzz?, :input_31 }
end
def fizz_with_input_31?
if number == 31
return false
else
fizz_without_input_31?
end
end
def buzz_with_input_31?
if number == 31
return false
else
buzz_without_input_31?
end
end
end
module FizzBuzz32
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_32 }
base.instance_eval { alias_method_chain :buzz?, :input_32 }
end
def fizz_with_input_32?
if number == 32
return false
else
fizz_without_input_32?
end
end
def buzz_with_input_32?
if number == 32
return false
else
buzz_without_input_32?
end
end
end
module FizzBuzz33
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_33 }
base.instance_eval { alias_method_chain :buzz?, :input_33 }
end
def fizz_with_input_33?
if number == 33
return true
else
fizz_without_input_33?
end
end
def buzz_with_input_33?
if number == 33
return false
else
buzz_without_input_33?
end
end
end
module FizzBuzz34
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_34 }
base.instance_eval { alias_method_chain :buzz?, :input_34 }
end
def fizz_with_input_34?
if number == 34
return false
else
fizz_without_input_34?
end
end
def buzz_with_input_34?
if number == 34
return false
else
buzz_without_input_34?
end
end
end
module FizzBuzz35
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_35 }
base.instance_eval { alias_method_chain :buzz?, :input_35 }
end
def fizz_with_input_35?
if number == 35
return false
else
fizz_without_input_35?
end
end
def buzz_with_input_35?
if number == 35
return true
else
buzz_without_input_35?
end
end
end
module FizzBuzz36
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_36 }
base.instance_eval { alias_method_chain :buzz?, :input_36 }
end
def fizz_with_input_36?
if number == 36
return true
else
fizz_without_input_36?
end
end
def buzz_with_input_36?
if number == 36
return false
else
buzz_without_input_36?
end
end
end
module FizzBuzz37
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_37 }
base.instance_eval { alias_method_chain :buzz?, :input_37 }
end
def fizz_with_input_37?
if number == 37
return false
else
fizz_without_input_37?
end
end
def buzz_with_input_37?
if number == 37
return false
else
buzz_without_input_37?
end
end
end
module FizzBuzz38
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_38 }
base.instance_eval { alias_method_chain :buzz?, :input_38 }
end
def fizz_with_input_38?
if number == 38
return false
else
fizz_without_input_38?
end
end
def buzz_with_input_38?
if number == 38
return false
else
buzz_without_input_38?
end
end
end
module FizzBuzz39
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_39 }
base.instance_eval { alias_method_chain :buzz?, :input_39 }
end
def fizz_with_input_39?
if number == 39
return true
else
fizz_without_input_39?
end
end
def buzz_with_input_39?
if number == 39
return false
else
buzz_without_input_39?
end
end
end
module FizzBuzz40
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_40 }
base.instance_eval { alias_method_chain :buzz?, :input_40 }
end
def fizz_with_input_40?
if number == 40
return false
else
fizz_without_input_40?
end
end
def buzz_with_input_40?
if number == 40
return true
else
buzz_without_input_40?
end
end
end
module FizzBuzz41
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_41 }
base.instance_eval { alias_method_chain :buzz?, :input_41 }
end
def fizz_with_input_41?
if number == 41
return false
else
fizz_without_input_41?
end
end
def buzz_with_input_41?
if number == 41
return false
else
buzz_without_input_41?
end
end
end
module FizzBuzz42
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_42 }
base.instance_eval { alias_method_chain :buzz?, :input_42 }
end
def fizz_with_input_42?
if number == 42
return true
else
fizz_without_input_42?
end
end
def buzz_with_input_42?
if number == 42
return false
else
buzz_without_input_42?
end
end
end
module FizzBuzz43
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_43 }
base.instance_eval { alias_method_chain :buzz?, :input_43 }
end
def fizz_with_input_43?
if number == 43
return false
else
fizz_without_input_43?
end
end
def buzz_with_input_43?
if number == 43
return false
else
buzz_without_input_43?
end
end
end
module FizzBuzz44
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_44 }
base.instance_eval { alias_method_chain :buzz?, :input_44 }
end
def fizz_with_input_44?
if number == 44
return false
else
fizz_without_input_44?
end
end
def buzz_with_input_44?
if number == 44
return false
else
buzz_without_input_44?
end
end
end
module FizzBuzz45
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_45 }
base.instance_eval { alias_method_chain :buzz?, :input_45 }
end
def fizz_with_input_45?
if number == 45
return true
else
fizz_without_input_45?
end
end
def buzz_with_input_45?
if number == 45
return true
else
buzz_without_input_45?
end
end
end
module FizzBuzz46
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_46 }
base.instance_eval { alias_method_chain :buzz?, :input_46 }
end
def fizz_with_input_46?
if number == 46
return false
else
fizz_without_input_46?
end
end
def buzz_with_input_46?
if number == 46
return false
else
buzz_without_input_46?
end
end
end
module FizzBuzz47
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_47 }
base.instance_eval { alias_method_chain :buzz?, :input_47 }
end
def fizz_with_input_47?
if number == 47
return false
else
fizz_without_input_47?
end
end
def buzz_with_input_47?
if number == 47
return false
else
buzz_without_input_47?
end
end
end
module FizzBuzz48
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_48 }
base.instance_eval { alias_method_chain :buzz?, :input_48 }
end
def fizz_with_input_48?
if number == 48
return true
else
fizz_without_input_48?
end
end
def buzz_with_input_48?
if number == 48
return false
else
buzz_without_input_48?
end
end
end
module FizzBuzz49
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_49 }
base.instance_eval { alias_method_chain :buzz?, :input_49 }
end
def fizz_with_input_49?
if number == 49
return false
else
fizz_without_input_49?
end
end
def buzz_with_input_49?
if number == 49
return false
else
buzz_without_input_49?
end
end
end
module FizzBuzz50
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_50 }
base.instance_eval { alias_method_chain :buzz?, :input_50 }
end
def fizz_with_input_50?
if number == 50
return false
else
fizz_without_input_50?
end
end
def buzz_with_input_50?
if number == 50
return true
else
buzz_without_input_50?
end
end
end
module FizzBuzz51
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_51 }
base.instance_eval { alias_method_chain :buzz?, :input_51 }
end
def fizz_with_input_51?
if number == 51
return true
else
fizz_without_input_51?
end
end
def buzz_with_input_51?
if number == 51
return false
else
buzz_without_input_51?
end
end
end
module FizzBuzz52
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_52 }
base.instance_eval { alias_method_chain :buzz?, :input_52 }
end
def fizz_with_input_52?
if number == 52
return false
else
fizz_without_input_52?
end
end
def buzz_with_input_52?
if number == 52
return false
else
buzz_without_input_52?
end
end
end
module FizzBuzz53
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_53 }
base.instance_eval { alias_method_chain :buzz?, :input_53 }
end
def fizz_with_input_53?
if number == 53
return false
else
fizz_without_input_53?
end
end
def buzz_with_input_53?
if number == 53
return false
else
buzz_without_input_53?
end
end
end
module FizzBuzz54
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_54 }
base.instance_eval { alias_method_chain :buzz?, :input_54 }
end
def fizz_with_input_54?
if number == 54
return true
else
fizz_without_input_54?
end
end
def buzz_with_input_54?
if number == 54
return false
else
buzz_without_input_54?
end
end
end
module FizzBuzz55
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_55 }
base.instance_eval { alias_method_chain :buzz?, :input_55 }
end
def fizz_with_input_55?
if number == 55
return false
else
fizz_without_input_55?
end
end
def buzz_with_input_55?
if number == 55
return true
else
buzz_without_input_55?
end
end
end
module FizzBuzz56
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_56 }
base.instance_eval { alias_method_chain :buzz?, :input_56 }
end
def fizz_with_input_56?
if number == 56
return false
else
fizz_without_input_56?
end
end
def buzz_with_input_56?
if number == 56
return false
else
buzz_without_input_56?
end
end
end
module FizzBuzz57
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_57 }
base.instance_eval { alias_method_chain :buzz?, :input_57 }
end
def fizz_with_input_57?
if number == 57
return true
else
fizz_without_input_57?
end
end
def buzz_with_input_57?
if number == 57
return false
else
buzz_without_input_57?
end
end
end
module FizzBuzz58
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_58 }
base.instance_eval { alias_method_chain :buzz?, :input_58 }
end
def fizz_with_input_58?
if number == 58
return false
else
fizz_without_input_58?
end
end
def buzz_with_input_58?
if number == 58
return false
else
buzz_without_input_58?
end
end
end
module FizzBuzz59
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_59 }
base.instance_eval { alias_method_chain :buzz?, :input_59 }
end
def fizz_with_input_59?
if number == 59
return false
else
fizz_without_input_59?
end
end
def buzz_with_input_59?
if number == 59
return false
else
buzz_without_input_59?
end
end
end
module FizzBuzz60
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_60 }
base.instance_eval { alias_method_chain :buzz?, :input_60 }
end
def fizz_with_input_60?
if number == 60
return true
else
fizz_without_input_60?
end
end
def buzz_with_input_60?
if number == 60
return true
else
buzz_without_input_60?
end
end
end
module FizzBuzz61
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_61 }
base.instance_eval { alias_method_chain :buzz?, :input_61 }
end
def fizz_with_input_61?
if number == 61
return false
else
fizz_without_input_61?
end
end
def buzz_with_input_61?
if number == 61
return false
else
buzz_without_input_61?
end
end
end
module FizzBuzz62
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_62 }
base.instance_eval { alias_method_chain :buzz?, :input_62 }
end
def fizz_with_input_62?
if number == 62
return false
else
fizz_without_input_62?
end
end
def buzz_with_input_62?
if number == 62
return false
else
buzz_without_input_62?
end
end
end
module FizzBuzz63
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_63 }
base.instance_eval { alias_method_chain :buzz?, :input_63 }
end
def fizz_with_input_63?
if number == 63
return true
else
fizz_without_input_63?
end
end
def buzz_with_input_63?
if number == 63
return false
else
buzz_without_input_63?
end
end
end
module FizzBuzz64
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_64 }
base.instance_eval { alias_method_chain :buzz?, :input_64 }
end
def fizz_with_input_64?
if number == 64
return false
else
fizz_without_input_64?
end
end
def buzz_with_input_64?
if number == 64
return false
else
buzz_without_input_64?
end
end
end
module FizzBuzz65
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_65 }
base.instance_eval { alias_method_chain :buzz?, :input_65 }
end
def fizz_with_input_65?
if number == 65
return false
else
fizz_without_input_65?
end
end
def buzz_with_input_65?
if number == 65
return true
else
buzz_without_input_65?
end
end
end
module FizzBuzz66
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_66 }
base.instance_eval { alias_method_chain :buzz?, :input_66 }
end
def fizz_with_input_66?
if number == 66
return true
else
fizz_without_input_66?
end
end
def buzz_with_input_66?
if number == 66
return false
else
buzz_without_input_66?
end
end
end
module FizzBuzz67
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_67 }
base.instance_eval { alias_method_chain :buzz?, :input_67 }
end
def fizz_with_input_67?
if number == 67
return false
else
fizz_without_input_67?
end
end
def buzz_with_input_67?
if number == 67
return false
else
buzz_without_input_67?
end
end
end
module FizzBuzz68
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_68 }
base.instance_eval { alias_method_chain :buzz?, :input_68 }
end
def fizz_with_input_68?
if number == 68
return false
else
fizz_without_input_68?
end
end
def buzz_with_input_68?
if number == 68
return false
else
buzz_without_input_68?
end
end
end
module FizzBuzz69
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_69 }
base.instance_eval { alias_method_chain :buzz?, :input_69 }
end
def fizz_with_input_69?
if number == 69
return true
else
fizz_without_input_69?
end
end
def buzz_with_input_69?
if number == 69
return false
else
buzz_without_input_69?
end
end
end
module FizzBuzz70
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_70 }
base.instance_eval { alias_method_chain :buzz?, :input_70 }
end
def fizz_with_input_70?
if number == 70
return false
else
fizz_without_input_70?
end
end
def buzz_with_input_70?
if number == 70
return true
else
buzz_without_input_70?
end
end
end
module FizzBuzz71
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_71 }
base.instance_eval { alias_method_chain :buzz?, :input_71 }
end
def fizz_with_input_71?
if number == 71
return false
else
fizz_without_input_71?
end
end
def buzz_with_input_71?
if number == 71
return false
else
buzz_without_input_71?
end
end
end
module FizzBuzz72
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_72 }
base.instance_eval { alias_method_chain :buzz?, :input_72 }
end
def fizz_with_input_72?
if number == 72
return true
else
fizz_without_input_72?
end
end
def buzz_with_input_72?
if number == 72
return false
else
buzz_without_input_72?
end
end
end
module FizzBuzz73
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_73 }
base.instance_eval { alias_method_chain :buzz?, :input_73 }
end
def fizz_with_input_73?
if number == 73
return false
else
fizz_without_input_73?
end
end
def buzz_with_input_73?
if number == 73
return false
else
buzz_without_input_73?
end
end
end
module FizzBuzz74
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_74 }
base.instance_eval { alias_method_chain :buzz?, :input_74 }
end
def fizz_with_input_74?
if number == 74
return false
else
fizz_without_input_74?
end
end
def buzz_with_input_74?
if number == 74
return false
else
buzz_without_input_74?
end
end
end
module FizzBuzz75
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_75 }
base.instance_eval { alias_method_chain :buzz?, :input_75 }
end
def fizz_with_input_75?
if number == 75
return true
else
fizz_without_input_75?
end
end
def buzz_with_input_75?
if number == 75
return true
else
buzz_without_input_75?
end
end
end
module FizzBuzz76
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_76 }
base.instance_eval { alias_method_chain :buzz?, :input_76 }
end
def fizz_with_input_76?
if number == 76
return false
else
fizz_without_input_76?
end
end
def buzz_with_input_76?
if number == 76
return false
else
buzz_without_input_76?
end
end
end
module FizzBuzz77
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_77 }
base.instance_eval { alias_method_chain :buzz?, :input_77 }
end
def fizz_with_input_77?
if number == 77
return false
else
fizz_without_input_77?
end
end
def buzz_with_input_77?
if number == 77
return false
else
buzz_without_input_77?
end
end
end
module FizzBuzz78
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_78 }
base.instance_eval { alias_method_chain :buzz?, :input_78 }
end
def fizz_with_input_78?
if number == 78
return true
else
fizz_without_input_78?
end
end
def buzz_with_input_78?
if number == 78
return false
else
buzz_without_input_78?
end
end
end
module FizzBuzz79
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_79 }
base.instance_eval { alias_method_chain :buzz?, :input_79 }
end
def fizz_with_input_79?
if number == 79
return false
else
fizz_without_input_79?
end
end
def buzz_with_input_79?
if number == 79
return false
else
buzz_without_input_79?
end
end
end
module FizzBuzz80
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_80 }
base.instance_eval { alias_method_chain :buzz?, :input_80 }
end
def fizz_with_input_80?
if number == 80
return false
else
fizz_without_input_80?
end
end
def buzz_with_input_80?
if number == 80
return true
else
buzz_without_input_80?
end
end
end
module FizzBuzz81
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_81 }
base.instance_eval { alias_method_chain :buzz?, :input_81 }
end
def fizz_with_input_81?
if number == 81
return true
else
fizz_without_input_81?
end
end
def buzz_with_input_81?
if number == 81
return false
else
buzz_without_input_81?
end
end
end
module FizzBuzz82
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_82 }
base.instance_eval { alias_method_chain :buzz?, :input_82 }
end
def fizz_with_input_82?
if number == 82
return false
else
fizz_without_input_82?
end
end
def buzz_with_input_82?
if number == 82
return false
else
buzz_without_input_82?
end
end
end
module FizzBuzz83
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_83 }
base.instance_eval { alias_method_chain :buzz?, :input_83 }
end
def fizz_with_input_83?
if number == 83
return false
else
fizz_without_input_83?
end
end
def buzz_with_input_83?
if number == 83
return false
else
buzz_without_input_83?
end
end
end
module FizzBuzz84
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_84 }
base.instance_eval { alias_method_chain :buzz?, :input_84 }
end
def fizz_with_input_84?
if number == 84
return true
else
fizz_without_input_84?
end
end
def buzz_with_input_84?
if number == 84
return false
else
buzz_without_input_84?
end
end
end
module FizzBuzz85
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_85 }
base.instance_eval { alias_method_chain :buzz?, :input_85 }
end
def fizz_with_input_85?
if number == 85
return false
else
fizz_without_input_85?
end
end
def buzz_with_input_85?
if number == 85
return true
else
buzz_without_input_85?
end
end
end
module FizzBuzz86
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_86 }
base.instance_eval { alias_method_chain :buzz?, :input_86 }
end
def fizz_with_input_86?
if number == 86
return false
else
fizz_without_input_86?
end
end
def buzz_with_input_86?
if number == 86
return false
else
buzz_without_input_86?
end
end
end
module FizzBuzz87
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_87 }
base.instance_eval { alias_method_chain :buzz?, :input_87 }
end
def fizz_with_input_87?
if number == 87
return true
else
fizz_without_input_87?
end
end
def buzz_with_input_87?
if number == 87
return false
else
buzz_without_input_87?
end
end
end
module FizzBuzz88
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_88 }
base.instance_eval { alias_method_chain :buzz?, :input_88 }
end
def fizz_with_input_88?
if number == 88
return false
else
fizz_without_input_88?
end
end
def buzz_with_input_88?
if number == 88
return false
else
buzz_without_input_88?
end
end
end
module FizzBuzz89
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_89 }
base.instance_eval { alias_method_chain :buzz?, :input_89 }
end
def fizz_with_input_89?
if number == 89
return false
else
fizz_without_input_89?
end
end
def buzz_with_input_89?
if number == 89
return false
else
buzz_without_input_89?
end
end
end
module FizzBuzz90
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_90 }
base.instance_eval { alias_method_chain :buzz?, :input_90 }
end
def fizz_with_input_90?
if number == 90
return true
else
fizz_without_input_90?
end
end
def buzz_with_input_90?
if number == 90
return true
else
buzz_without_input_90?
end
end
end
module FizzBuzz91
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_91 }
base.instance_eval { alias_method_chain :buzz?, :input_91 }
end
def fizz_with_input_91?
if number == 91
return false
else
fizz_without_input_91?
end
end
def buzz_with_input_91?
if number == 91
return false
else
buzz_without_input_91?
end
end
end
module FizzBuzz92
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_92 }
base.instance_eval { alias_method_chain :buzz?, :input_92 }
end
def fizz_with_input_92?
if number == 92
return false
else
fizz_without_input_92?
end
end
def buzz_with_input_92?
if number == 92
return false
else
buzz_without_input_92?
end
end
end
module FizzBuzz93
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_93 }
base.instance_eval { alias_method_chain :buzz?, :input_93 }
end
def fizz_with_input_93?
if number == 93
return true
else
fizz_without_input_93?
end
end
def buzz_with_input_93?
if number == 93
return false
else
buzz_without_input_93?
end
end
end
module FizzBuzz94
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_94 }
base.instance_eval { alias_method_chain :buzz?, :input_94 }
end
def fizz_with_input_94?
if number == 94
return false
else
fizz_without_input_94?
end
end
def buzz_with_input_94?
if number == 94
return false
else
buzz_without_input_94?
end
end
end
module FizzBuzz95
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_95 }
base.instance_eval { alias_method_chain :buzz?, :input_95 }
end
def fizz_with_input_95?
if number == 95
return false
else
fizz_without_input_95?
end
end
def buzz_with_input_95?
if number == 95
return true
else
buzz_without_input_95?
end
end
end
module FizzBuzz96
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_96 }
base.instance_eval { alias_method_chain :buzz?, :input_96 }
end
def fizz_with_input_96?
if number == 96
return true
else
fizz_without_input_96?
end
end
def buzz_with_input_96?
if number == 96
return false
else
buzz_without_input_96?
end
end
end
module FizzBuzz97
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_97 }
base.instance_eval { alias_method_chain :buzz?, :input_97 }
end
def fizz_with_input_97?
if number == 97
return false
else
fizz_without_input_97?
end
end
def buzz_with_input_97?
if number == 97
return false
else
buzz_without_input_97?
end
end
end
module FizzBuzz98
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_98 }
base.instance_eval { alias_method_chain :buzz?, :input_98 }
end
def fizz_with_input_98?
if number == 98
return false
else
fizz_without_input_98?
end
end
def buzz_with_input_98?
if number == 98
return false
else
buzz_without_input_98?
end
end
end
module FizzBuzz99
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_99 }
base.instance_eval { alias_method_chain :buzz?, :input_99 }
end
def fizz_with_input_99?
if number == 99
return true
else
fizz_without_input_99?
end
end
def buzz_with_input_99?
if number == 99
return false
else
buzz_without_input_99?
end
end
end
module FizzBuzz100
def self.included(base)
base.instance_eval { alias_method_chain :fizz?, :input_100 }
base.instance_eval { alias_method_chain :buzz?, :input_100 }
end
def fizz_with_input_100?
if number == 100
return false
else
fizz_without_input_100?
end
end
def buzz_with_input_100?
if number == 100
return true
else
buzz_without_input_100?
end
end
end
class FizzBuzz
include FizzBuzz1
include FizzBuzz2
include FizzBuzz3
include FizzBuzz4
include FizzBuzz5
include FizzBuzz6
include FizzBuzz7
include FizzBuzz8
include FizzBuzz9
include FizzBuzz10
include FizzBuzz11
include FizzBuzz12
include FizzBuzz13
include FizzBuzz14
include FizzBuzz15
include FizzBuzz16
include FizzBuzz17
include FizzBuzz18
include FizzBuzz19
include FizzBuzz20
include FizzBuzz21
include FizzBuzz22
include FizzBuzz23
include FizzBuzz24
include FizzBuzz25
include FizzBuzz26
include FizzBuzz27
include FizzBuzz28
include FizzBuzz29
include FizzBuzz30
include FizzBuzz31
include FizzBuzz32
include FizzBuzz33
include FizzBuzz34
include FizzBuzz35
include FizzBuzz36
include FizzBuzz37
include FizzBuzz38
include FizzBuzz39
include FizzBuzz40
include FizzBuzz41
include FizzBuzz42
include FizzBuzz43
include FizzBuzz44
include FizzBuzz45
include FizzBuzz46
include FizzBuzz47
include FizzBuzz48
include FizzBuzz49
include FizzBuzz50
include FizzBuzz51
include FizzBuzz52
include FizzBuzz53
include FizzBuzz54
include FizzBuzz55
include FizzBuzz56
include FizzBuzz57
include FizzBuzz58
include FizzBuzz59
include FizzBuzz60
include FizzBuzz61
include FizzBuzz62
include FizzBuzz63
include FizzBuzz64
include FizzBuzz65
include FizzBuzz66
include FizzBuzz67
include FizzBuzz68
include FizzBuzz69
include FizzBuzz70
include FizzBuzz71
include FizzBuzz72
include FizzBuzz73
include FizzBuzz74
include FizzBuzz75
include FizzBuzz76
include FizzBuzz77
include FizzBuzz78
include FizzBuzz79
include FizzBuzz80
include FizzBuzz81
include FizzBuzz82
include FizzBuzz83
include FizzBuzz84
include FizzBuzz85
include FizzBuzz86
include FizzBuzz87
include FizzBuzz88
include FizzBuzz89
include FizzBuzz90
include FizzBuzz91
include FizzBuzz92
include FizzBuzz93
include FizzBuzz94
include FizzBuzz95
include FizzBuzz96
include FizzBuzz97
include FizzBuzz98
include FizzBuzz99
include FizzBuzz100
end
(1..100).each do |i|
number = FizzBuzz.new(i)
if number.fizz? && number.buzz?
puts "FizzBuzz"
elsif number.fizz?
puts "Fizz"
elsif number.buzz?
puts "Buzz"
else
puts number
end
end
So, after seeing some ugly fizzbuzzes, instead of trying to create the best fizzbuzz ever (an easy task), we decided the worst fizzbuzz ever would be a bigger challenge.
Oh, and before you ask, it's because spaceships are awesome.