-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruby_test.rb
More file actions
148 lines (128 loc) · 2.92 KB
/
Copy pathruby_test.rb
File metadata and controls
148 lines (128 loc) · 2.92 KB
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
146
147
148
def rnd(min,max)
rand(max+1-min) + min
end
SERIES = 120
# GitHub test
def easy_add
(1..SERIES).each {
a = rnd(1,20)
b = rnd(1,20)
puts "EASY ADD " + a.to_s + " + " + b.to_s + " = " + (a+b).to_s
}
end
def easy_sub
(1..SERIES).each {
a = rnd(1,40)
b = rnd(1,a)
puts "EASY SUB " + a.to_s + " - " + b.to_s + " = " + (a-b).to_s
}
end
def easy_mul
(1..SERIES).each {
a = rnd(1,10)
b = rnd(1,10)
puts "EASY MULTIP " + a.to_s + " * " + b.to_s + " = " + (a*b).to_s
}
end
def easy_div
(1..SERIES).each {
b = rnd(1,10)
a = rnd(1,10) * b
puts "EASY DIV " + a.to_s + " / " + b.to_s + " = " + (a/b).to_s
}
end
def easy_perc
(1..SERIES).each {
a = rnd(1,9)*10
b = rnd(1,10) * 10
puts "EASY PERC " + a.to_s + " % " + b.to_s + " = " + (a*b/100).to_s
}
end
def medium_add
(1..SERIES).each {
a = rnd(1,100)
b = rnd(1,100)
puts "MEDIUM ADD " + a.to_s + " + " + b.to_s + " = " + (a+b).to_s
}
end
def medium_sub
(1..SERIES).each {
a = rnd(1,200)
b = rnd(1,a)
puts "MEDIUM SUB " + a.to_s + " - " + b.to_s + " = " + (a-b).to_s
}
end
def medium_mul
(1..SERIES).each {
a = [1,10,100][rnd(0,2)]*rnd(1,20)
b = [1,10,100][rnd(0,2)]*rnd(1,20)
puts "MEDIUM MULTIP " + a.to_s + " * " + b.to_s + " = " + (a*b).to_s
}
end
def medium_div
(1..SERIES).each {
b = [1,10][rnd(0,1)]*rnd(1,10)
a = [1,10][rnd(0,1)]*rnd(1,10)
puts "MEDIUM DIV " + (a*b).to_s + " / " + b.to_s + " = " + (a*b/b).to_s
}
end
def medium_perc
(1..SERIES).each {
a = [10,20,30,40,50,60,70,80,90,25,75][rnd(0,10)]
b = [100,1000,10000][rnd(0,2)]*rnd(1,10)
puts "MEDIUM PERC " + a.to_s + " % " + b.to_s + " = " + (a*b/100).to_s
}
end
def hard_add
(1..SERIES).each {
a = rnd(1,1000)
b = rnd(1,1000)
puts "HARD ADD " +a.to_s + " + " + b.to_s + " = " + (a+b).to_s
}
end
def hard_sub
(1..SERIES).each {
a = rnd(1,500)
b = rnd(1,a)
puts "HARD SUB " + a.to_s + " - " + b.to_s + " = " + (a-b).to_s
}
end
def hard_mul
(1..SERIES).each {
a = [100,1000,10000,1000000][rnd(0,3)]*rnd(1,19)
max_factor = 9 - Math::log10(a).to_i
# BUG
b = (10**rnd(0,max_factor)) * rnd(1,10)
puts "HARD MULTIP " + a.to_s + " * " + b.to_s + " = " + ("%E" % (a*b))
}
end
def hard_div
(1..SERIES).each {
b_factor = rnd(2,9)
b = [1,10][rnd(0,1)]*b_factor
a = b * [10000, 100000, 1000000, 10000000, 100000000][rnd(0,4)]*rnd(2,9)
puts "HARD DIV " + a.to_s + " / " + b.to_s + " = " + ("%E" % (a/b))
}
end
def hard_perc
(1..SERIES).each {
a = [10,20,30,40,50,60,70,80,90,25,75][rnd(0,10)]
b = [10000, 100000, 1000000, 10000000, 100000000][rnd(0,4)]*rnd(1,20)
puts "HARD PERC " + a.to_s + " % " + b.to_s + " = " + (a*b/100).to_s
}
end
#easy_add
#easy_sub
#easy_mul
#easy_div
#easy_perc
#medium_add
#medium_sub
#medium_mul
#medium_div
#medium_perc
#hard_add
#hard_sub
hard_mul
#hard_div
#hard_perc