-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadv2.rb
145 lines (125 loc) · 2.57 KB
/
adv2.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
yes_no = Array["yes", "no"]
directions = Array["left", "right", "backward", "forward"]
#Introduction
puts("What is your name, adventurer?")
name = gets.chomp()
puts("Greetings, "+name+". Lets go on a quick quest!")
puts("You find yourself on the edge of dark forest")
puts("Can you find your way through?")
#Start of the game
resp = ""
condition = yes_no.include? resp == false
while condition == false
puts("Would you like to step into the forest?")
puts("yes/no")
resp = gets.chomp()
if resp = "yes"
puts("You head into the forest. You hear crows cawwing in the distance")
break
elsif resp == "no"
puts("You are not ready for this quest. Goodbye!")
break
else
puts("I didn't understand that!")
end
end
#Next part
resp = ""
condition = directions.include? resp == false
while condition == false
puts("To the left, you see a bear.")
puts("To the right, there is killer bees")
puts("There is a rock wall directly in front of you")
puts("Behind you is the forest exit.")
puts("What direction do you move?")
resp = gets.chomp()
if resp == "left"
puts("The bear eats you. Farewell, " + name+".")
break
elsif resp == "right"
puts("You are killed by killer bees. Farewell, " + name+".")
break
elsif resp == "forward"
puts("You cannot scale the wall.")
resp = ""
elsif resp == "backward"
puts("You leave the forest. Goodbye, "+name+".")
break
else
puts("I did not understand that")
end
end
i = 10
while i > 0
puts(i)
i -= 1
end
nums = []
i = 0
while i <= 80
nums.append(i)
i += 1
end
for i in nums do
if i % 2 == 1
puts(i)
end
end
list1 = [10, 20, 23, 11, 17]
list2 = [13, 43, 24, 36, 12]
list3 = []
for i in list1 do
if i % 2 == 1
list3.append(i)
end
end
for j in list2 do
if j % 2 == 0
list3.append(j)
end
end
puts(list3)
i = 10
while i > 0
puts(i)
i -= 1
puts("Done")
end
list = []
i = 2
while i <= 100
list.append(i)
i += 1
end
for i in list do
if i == 2 or i == 3 or i == 5
puts(i)
end
if i % 2 == 1
if i % 3 != 0
if i % 5 != 0
puts(i)
end
end
end
end
arr = [1,3,4,5,6,7,8,9,0,2]
for i in arr do
puts(i*i)
end
def even_nums()
list = []
even_num = []
i = 4
while i <= 30
list.append(i)
i += 1
end
for i in list do
if i % 2 == 0
even_num.append(i)
end
end
puts(even_num)
end
even_nums()