Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - ZERO = None
 - def succ(prior):
 - return [prior]
 - def pred(x):
 - for val in x:
 - return val
 - raise Exception("Nope")
 - ONE = succ(ZERO)
 - TWO = succ(ONE)
 - THREE = succ(TWO)
 - FOUR = succ(THREE)
 - FIVE = succ(FOUR)
 - SIX = succ(FIVE)
 - SEVEN = succ(SIX)
 - EIGHT = succ(SEVEN)
 - NINE = succ(EIGHT)
 - TEN = succ(NINE)
 - def add(a, b):
 - x = a
 - y = b
 - while x is not None:
 - x = pred(x)
 - y = [y]
 - return y
 - def multiply(a,b):
 - x = a
 - y = None
 - while x is not None:
 - x = pred(x)
 - y = add(y, b)
 - return y
 - def roman_digits_pattern(lo, hi, hihi):
 - return [
 - '',
 - lo,
 - "".join([lo, lo]),
 - "".join([lo, lo, lo]),
 - "".join([lo, hi]),
 - hi,
 - "".join([hi, lo]),
 - "".join([hi, lo, lo]),
 - "".join([hi, lo, lo, lo]),
 - "".join([lo, hihi])
 - ]
 - def build_roman_table():
 - tens = roman_digits_pattern('I', 'V', 'X')
 - hundreds = roman_digits_pattern('X', 'L', 'C')
 - thousands = roman_digits_pattern('C', 'D', 'M')
 - table = []
 - for a in thousands:
 - for b in hundreds:
 - for c in tens:
 - table.append("".join([a,b,c]))
 - return table
 - ROMAN_DIGITS = build_roman_table()
 - def print_number(x):
 - z = x
 - for digit in ROMAN_DIGITS:
 - if z is None:
 - print(digit)
 - return
 - z = pred(z)
 - def fizz_buzz(limit):
 - div_by_five = FOUR
 - div_by_three = TWO
 - at = ONE
 - x = limit
 - while x is not None:
 - x = pred(x)
 - result = []
 - show_number = True
 - if div_by_three is None:
 - show_number = False
 - div_by_three = THREE
 - result.append("Fizz")
 - if div_by_five is None:
 - show_number = False
 - div_by_five = FIVE
 - result.append("Buzz")
 - if show_number:
 - print_number(at)
 - else:
 - print("".join(result))
 - div_by_three = pred(div_by_three)
 - div_by_five = pred(div_by_five)
 - at = succ(at)
 - ONE_HUNDRED = multiply(TEN, TEN)
 - fizz_buzz(ONE_HUNDRED)
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment