-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagicNumber.rb
58 lines (58 loc) · 1.05 KB
/
magicNumber.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def magic
puts "Spell out a number"
input = gets.gsub!(/\s+/, "")
newNum=input.length
puts "Here we go!"
puts " #{input} equals #{newNum}"
while newNum != 4 do
case newNum
when 1
puts "one equals three"
newNum = 3
when 2
puts "two equals three"
newNum = 3
when 3
puts "three equals five"
newNum = 5
when 5
puts "five equals four"
newNum = 4
when 6
puts "six equals three"
newNum = 3
when 7
puts "seven equals five"
newNum = 5
when 8
puts "eight equals five"
newNum = 5
when 9
puts "nine equals four"
newNum = 4
when 10
puts "ten equals three"
newNum = 3
when 11
puts "eleven equals six"
newNum = 6
else
puts "#{newNum} equals... yeah I give up."
puts "For I am a simple bot that knows his limits."
puts "Maybe give me a smaller number?"
newNum = 4
end
end
puts "and four is the magic number!"
again
end
def again
puts "want to play again?"
print "(y/n)>"
if gets.strip == "y"
magic
else
puts "I understand"
end
end
magic