mathsuite_gem 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d05302df4fb048e09d80295e464559ce6c91b5c2a7c1956cf557ab851fa36b9b
4
+ data.tar.gz: 025473fde133a319afc7e5f6c8f55836e63e4632bf32301a1f28fff90d89b242
5
+ SHA512:
6
+ metadata.gz: 35d5dba671ffb78ce1a42432c9bd253eba40c6f5a582631b57dfb4fe9bb4fbea20ca212b7ff6818cad920a487170e30cf72b3a6efc3ce4b8408e62c9d71c7fa5
7
+ data.tar.gz: 6293f85c8c3f572e88a059632cb4ad529c3f96a16ce6d6182253fea78127be4e7b5c7e675dce6619fcaa3be905b20d89df628e4e44f75d534b66f59fe2e6c6fe
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 westnick2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Mathsuite
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mathsuite`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mathsuite'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mathsuite
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mathsuite. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Mathsuite project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mathsuite/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,327 @@
1
+
2
+ class Mathsuite
3
+ class << self
4
+
5
+ def dz1(a, b)
6
+ { summa: a+b, diff: a-b, multiply: a*b }
7
+ end
8
+
9
+ def dz2(x, y)
10
+ { value: (x.abs -y.abs)/(1+(x*y).abs) }
11
+ end
12
+
13
+ def dz3(x)
14
+ { volume: x**3,surface_area: x**2}
15
+ end
16
+
17
+ def dz4(x, y)
18
+ { sr_arifmet: (x+y)/2, sr_geometr: Math.sqrt(x*y)}
19
+ end
20
+
21
+ def dz5(x, y)
22
+ { sr_arifmet: (x+y)/2, sr_geometr: Math.sqrt(x.abs*y.abs)}
23
+ end
24
+
25
+ def dz6(x, y)
26
+ { gipotenuza: Math.sqrt(x**2+y**2), square: (x.abs*y.abs)/2}
27
+ end
28
+
29
+ def dz7(v1, t1, v2, t2)
30
+ { volume_M3: (v1+v2)/1000, temperature: (v1*1*t1+v2*1*t2)/(v1*1+v2*1) }
31
+ end
32
+
33
+ def dz8(n, r)
34
+ { Perimetr: r*Math.tan(360/(2*n))*2*n}
35
+ end
36
+
37
+ def dz9(r1, r2, r3)
38
+ { resistance: (r1*r2*r3)/(r2*r3+r1*r3+r1*r2)}
39
+ end
40
+
41
+ def dz10(h)
42
+ { falling_time: Math.sqrt(2*h/9.8) }
43
+ end
44
+
45
+ def dz11(x, y, z)
46
+ { a: (Math.sqrt((x-1).abs)-(y.abs)**1.0/3.0)/(1+x**2/2+y**2/4) , b: x*(Math.atan(z)+Math.exp(-x-3))}
47
+ end
48
+
49
+ def dz12(a)
50
+ { triangel_square: a**2*Math.sqrt(3)/4}
51
+ end
52
+
53
+ def dz13(l)
54
+ { Period_mayatnika: 2*Math::PI * Math.sqrt(l)/9.8}
55
+ end
56
+
57
+ def dz14(m1, m2, r)
58
+ g = 6.7385/10**11
59
+ if r.nonzero?
60
+ f = g.to_f*m1*m2/r**2
61
+ else
62
+ f = 0
63
+ end
64
+ end
65
+
66
+ def dz15(a, b)
67
+ c = Math.sqrt(a**2-b**2)
68
+ p = (a+b+c)/2
69
+ r = Math.sqrt((p-a)*(p-b)*(p-c)/p)
70
+ { katet2: c, radius: r}
71
+ end
72
+
73
+ def dz16(p)
74
+ { square: p**2/(8*Math::PI)}
75
+ end
76
+
77
+ def dz17(r1,r2)
78
+ { circle_square: Math::PI*(r2**2-r1**2)/2}
79
+ end
80
+
81
+ def dz18(a, b, c)
82
+ a = 2*r* Math.sin(alpha*Math::PI/180)
83
+ b = 2*r* Math.sin(beta*Math::PI/180)
84
+ c = 2*r* Math.sin(gama*Math::PI/180)
85
+ {a: a,b: b,c: c}
86
+ end
87
+
88
+ def dz19(v1, v2, a1, a2, s)
89
+ t = ((-2*(v1+v2))+Math.sqrt(4*((v1+v2)**2)+8*(a1+a2)*s))/2*(a1+a2);
90
+ { t: t}
91
+ end
92
+
93
+ def dz20(a, d, n)
94
+ { summa: (2*a + d*(n-1))*n/2}
95
+ end
96
+
97
+ def dz33(x, y)
98
+ a = [x,y]
99
+ var_max = a.max()
100
+ var_min = a.min()
101
+ { max: var_max, min:var_min}
102
+ end
103
+
104
+ def dz34(x, y, z)
105
+ a = [x,y,z]
106
+ var_max = a.max()
107
+ var_min = a.min()
108
+ [{ max: var_max}, {min:var_min, max1: var_max}]
109
+ end
110
+
111
+ def dz35(x, y, z)
112
+ a = [x+y+z,x*y*z]
113
+ b = [x+y+z/2.0,x*y*z]
114
+ var_max = a.max()
115
+ var_min = b.min()**2+1
116
+ { max: var_max, min:var_min }
117
+ end
118
+
119
+ def dz36(a, b, c)
120
+ if a<b &&b<c
121
+ {a_Less_b_Less_c: true}
122
+ else
123
+ {a_Less_b_Less_c: false}
124
+ end
125
+ end
126
+
127
+ def dz37(a, b, c)
128
+ if c<=b &&b<=a
129
+ [a,b,c].each {|x| x*2}
130
+ else
131
+ [a,b,c].each {|x| x.abs}
132
+ end
133
+ end
134
+
135
+ def dz38(x,y)
136
+ if x>y
137
+ z = x-y
138
+ else
139
+ z = y-x+1
140
+ end
141
+ { z: z}
142
+ end
143
+
144
+ def dz39(x, y)
145
+ if x>y
146
+ z =x
147
+ else
148
+ z = [x,y]
149
+ end
150
+ { z: z}
151
+ end
152
+
153
+ def dz40(x, y)
154
+ x=0 if x <= y
155
+ { result: [x, y] }
156
+ end
157
+
158
+ def dz41(x, y, z)
159
+ { res: [x,y,z].select {|a| (a>1) && (a<3) }}
160
+ end
161
+
162
+ def dz42(x, y)
163
+ if x == y
164
+ return "must be x!=y"
165
+ elsif x<y
166
+ x_tmp = x
167
+ x = (x+y)/2.0
168
+ y = 2*x_tmp*y
169
+ else
170
+ y_tmp = y
171
+ y = (x+y)/2.0
172
+ x = 2*y_tmp*x
173
+ end
174
+ { res: [x, y]}
175
+ end
176
+
177
+ def dz43(x, y, z)
178
+ { res: [x,y,z].each {|a| a = a**2 if a >= 0} }
179
+ end
180
+
181
+ def dz77(n)
182
+ fact = n.downto(1).inject(:*)
183
+ { n2: 2**n, fact: fact}
184
+ end
185
+
186
+ def dz196()
187
+ ar = []
188
+ x =10
189
+ 1.upto(50) do
190
+ ar.push(x)
191
+ x+=1
192
+ end
193
+ { arB: ar.each.map { |x| if x.odd?
194
+ x=x*2
195
+ else
196
+ x = x
197
+ end } }
198
+ end
199
+
200
+ def dz200(a, n)
201
+ if !((1..n).to_a.include?(a))
202
+ return 0
203
+ else
204
+ i = 0
205
+ (1..n).to_a.each do |x|
206
+ if x==a
207
+ return i
208
+ end
209
+ i+=1
210
+ end
211
+ end
212
+ { res: "no #{a} in sequence"}
213
+ end
214
+
215
+ def dz204(n)
216
+ score = []
217
+ 1.upto(n) {|x| score.push (x+2) }
218
+ score.sort!.shift
219
+ score.pop
220
+ { score: score.inject{ |sum, el| sum + el }.to_f/score.size }
221
+ end
222
+
223
+ def dz205(str)
224
+ { res: str.chars.delete_if { |x| x=="0"||x=="5" }.join }
225
+ end
226
+
227
+ def dz224(n)
228
+ { res: (1..n).select { |x| x = x if (n % x).zero?} }
229
+ end
230
+
231
+ def dz225(n)
232
+ { res: (1..n).select { |x| (n % x**2).zero? && (n % x**3).nonzero?} }
233
+ end
234
+
235
+ def dz251(str)
236
+ { res:str.chars.count("x")}
237
+ end
238
+
239
+ def dz258(str, char1)
240
+ { res: str.chars.delete(char1) }
241
+ end
242
+
243
+ def dz259(str, char1)
244
+ ar = str.chars.delete_if{|x| x== char1 }
245
+ { res: ar.map { |x| x = x + x if x!=char1 } }
246
+ end
247
+
248
+ def dz330(n)
249
+ res = []
250
+ 1.upto(n) do |x|
251
+ ar = (1..x).select { |y| (n % y).zero? ? y = y : y = 0}
252
+ if x.equal?(ar.sum())
253
+ res.push(x)
254
+ end
255
+ end
256
+ { res_perfect_num: res}
257
+ end
258
+
259
+ def dz331(num)
260
+ res = []
261
+ 1.upto(num) do |x|
262
+ 1.upto(num) do |y|
263
+ 1.upto(num) do |z|
264
+ summa = (x**2) + (y**2) + (z**2)
265
+ res.push([x,y,z]) if summa.equal?(num)
266
+ end
267
+ end
268
+ end
269
+ { res_num: res}
270
+ end
271
+
272
+ def dz332(num)
273
+ res = []
274
+ 1.upto(num) do |x|
275
+ 1.upto(num) do |y|
276
+ 1.upto(num) do |z|
277
+ 1.upto(num) do |t|
278
+ summa = (x**2) + (y**2) + (z**2)+(t**2)
279
+ res.push([x,y,z,t]) if summa.equal?(num)
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+
286
+ def dz347(array)
287
+ mmin = array.min
288
+ mmax = array.max
289
+ enumer = mmin..mmax
290
+ { numbers: enumer.reject { |x| array.include?(x) } }
291
+ end
292
+
293
+ def dz434(aarr, barr)
294
+ ares = aarr.map.with_index { |x, i| i > aarr.index(aarr.max)? x = 0.5 : x }
295
+ bres = barr.map.with_index { |x, i| i > barr.index(barr.max)? x = 0.5 : x}
296
+ { ares: ares, bres: bres}
297
+ end
298
+
299
+ def dz435(aarr, barr, k)
300
+ aarr[aarr.index(aarr.max)] = k unless aarr.include?(k)
301
+ barr[barr.index(barr.max)] = k unless barr.include?(k)
302
+ { aarr: aarr, barr: barr}
303
+ end
304
+
305
+ def dz462(char1)
306
+ if (('a'..'z').include?(char1)) || (('A'..'Z').include?(char1))
307
+ { is_a_letter?: true }
308
+ else
309
+ { is_a_letter?: false }
310
+ end
311
+ end
312
+
313
+ def dz468(str1, str2)
314
+ flag = false
315
+ str2.chars.each do |x|
316
+ flag = str1.include?(x)
317
+ return { sym: x, index: str1.chars.index(x)} if flag
318
+ end
319
+ -1 unless flag
320
+ end
321
+
322
+ def dz469(str1, width)
323
+ delta = width - str1.size
324
+ str1.chars.select { |char| char == " " ? (char << " ") : (char = char) }.join
325
+ end
326
+ end
327
+ end
@@ -0,0 +1,33 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'mathsuite_gem'
3
+ s.version = '1.0.1'
4
+ s.date = '2018-11-12'
5
+
6
+ s.summary = "Solving Abramov book math tasks."
7
+ s.description = "This gem will help you to solve Abramov book math tasks."
8
+
9
+ s.authors = ["Metelap Vlad"]
10
+ s.email = 'vmetww@gmail.com'
11
+
12
+ s.files = ["lib/mathsuite.rb"]
13
+ s.homepage = 'https://github.com/westnick2/mathsuite'
14
+ s.license = 'GPL-2.0'
15
+
16
+ s.require_paths = ['lib']
17
+
18
+ s.add_development_dependency 'mathtestsuite', '~> 1.0'
19
+
20
+ s.files = [
21
+ 'LICENSE.txt',
22
+ 'README.md',
23
+ 'Rakefile',
24
+ 'mathsuite.gemspec',
25
+ 'lib/mathsuite.rb',
26
+ 'test/spec.rb'
27
+ ]
28
+
29
+ s.test_files = [
30
+ 'test/spec.rb'
31
+ ]
32
+
33
+ end
@@ -0,0 +1,300 @@
1
+ load 'lib/mathsuite.rb'
2
+ require 'mathtestsuite'
3
+
4
+ class Spec
5
+ include Mathtestsuite
6
+
7
+ def dz1_t1
8
+ expected_value = { summa: -5, diff: 1, multiply: 6 }
9
+ assert(expected: expected_value, actual: Mathsuite.dz1(-2.0, -3.0))
10
+ end
11
+
12
+ def dz1_t2
13
+ expected_value = { summa: 9, diff: 5, multiply: 10 }
14
+ assert(expected: expected_value, actual: Mathsuite.dz1(-2.0, -3.0))
15
+ end
16
+
17
+ def dz2_t1
18
+ expected_value = {value: 0}
19
+ assert(expected: expected_value, actual: Mathsuite.dz2(-3.0, -3.0))
20
+ end
21
+
22
+ def dz3_t1
23
+ expected_value = {volume: 10**3,surface_area: 10**2}
24
+ assert(expected: expected_value, actual: Mathsuite.dz3(10))
25
+ end
26
+
27
+ def dz4_t1
28
+ expected_value = {sr_arifmet: 15.0, sr_geometr: Math.sqrt(10.0*20.0)}
29
+ assert(expected: expected_value, actual: Mathsuite.dz4(10, 20))
30
+ end
31
+
32
+ def dz5_t1
33
+ expected_value = {sr_arifmet: 10.0, sr_geometr: 10.0}
34
+ assert(expected: expected_value, actual: Mathsuite.dz5(10, 10))
35
+ end
36
+
37
+ def dz6_t1
38
+ expected_value = {gipotenuza: 5, square: 6.0}
39
+ assert(expected: expected_value, actual: Mathsuite.dz6(3.0, 4.0))
40
+ end
41
+
42
+ def dz7_t1
43
+ expected_value = {volume_M3: 30/1000, temperature: (10*1*40+20*1*20)/(10*1+20*1) }
44
+ assert(expected: expected_value, actual: Mathsuite.dz7(10.0, 40.0,20.0,20.0))
45
+ end
46
+
47
+ def dz8_t1
48
+ expected_value = {Perimetr: 5*Math.tan(360/(2*8))*2*8}
49
+ assert(expected: expected_value, actual: Mathsuite.dz8(8,5))
50
+ end
51
+
52
+ def dz9_t1
53
+ expected_value = {resistance: (10*15*25)/(15*25+10*25+10*15)}
54
+ assert(expected: expected_value, actual: Mathsuite.dz9(10,15,25))
55
+ end
56
+
57
+ def dz10_t1
58
+ expected_value = {falling_time: Math.sqrt(2*100/9.8) }
59
+ assert(expected: expected_value, actual: Mathsuite.dz10(100.0))
60
+ end
61
+
62
+ def dz11_t1
63
+ expected_value = {a: (Math.sqrt((10-1).abs)-(12.abs)**1.0/3.0)/(1+10**2/2+12**2/4) , b: 10*(Math.atan(15)+Math.exp(-10-3))}
64
+ assert(expected: expected_value, actual: Mathsuite.dz11(10,12,15))
65
+ end
66
+
67
+ def dz12_t1
68
+ expected_value = {triangel_square: 10**2*Math.sqrt(3)/4}
69
+ assert(expected: expected_value, actual: Mathsuite.dz12(10.0))
70
+ end
71
+
72
+ def dz13_t1
73
+ expected_value = {Period_mayatnika: 2*Math::PI * Math.sqrt(20)/9.8}
74
+ assert(expected: expected_value, actual: Mathsuite.dz13(20))
75
+ end
76
+
77
+ def dz14_t1
78
+ g = 6.7385/10**11
79
+ expected_value = {force_of_gravity: g*100*200/10**2}
80
+ assert(expected: expected_value, actual: Mathsuite.dz14(100,200,10,g))
81
+ end
82
+
83
+ def dz15_t1
84
+ gipotenuza = 5
85
+ katet = 4
86
+ katet2 = Math.sqrt(gipotenuza**2-katet**2)
87
+ p = (gipotenuza+katet+katet2)/2
88
+ r = Math.sqrt((p-gipotenuza)*(p-katet)*(p-katet2)/p)
89
+ expected_value = {katet2: katet2, radius: r}
90
+ assert(expected: expected_value, actual: Mathsuite.dz15(5,4))
91
+ end
92
+
93
+ def dz16_t1
94
+ expected_value = {square: 100**2/(8*Math::PI)}
95
+ assert(expected: expected_value, actual: Mathsuite.dz16(100.0))
96
+ end
97
+
98
+ def dz17_t1
99
+ expected_value = {circle_square: Math::PI*(30**2-20**2)/2}
100
+ assert(expected: expected_value, actual: Mathsuite.dz17(20,30))
101
+ end
102
+
103
+ def dz18_t1
104
+ a = 2*5* Math.sin(60*Math::PI/180)
105
+ b = 2*5* Math.sin(60*Math::PI/180)
106
+ c = 2*5* Math.sin(60*Math::PI/180)
107
+ expected_value = {a: a,b: b,c: c}
108
+ assert(expected: expected_value, actual: Mathsuite.dz18(60,60,60,5))
109
+ end
110
+
111
+ def dz19_t1
112
+ t = ((-2*(v1+v2))+Math.sqrt(4*((v1+v2)**2)+8*(a1+a2)*s))/2*(a1+a2);
113
+ expected_value = {t: t}
114
+ assert(expected: expected_value, actual: Mathsuite.dz19(50,60,10,5,1000))
115
+ end
116
+
117
+ def dz20_t1
118
+ expected_value = {summa: (2*3 + 2*(20-1))*20/2}
119
+ assert(expected: expected_value, actual: Mathsuite.dz20(3,2,20))
120
+ end
121
+
122
+ def dz33_t1
123
+ expected_value = {max: 100, min:20}
124
+ assert(expected: expected_value, actual: Mathsuite.dz33(20,100))
125
+ end
126
+
127
+ def dz34_t1
128
+ expected_value = [{max: 30}, {min:10, max1: 30}]
129
+ assert(expected: expected_value, actual: Mathsuite.dz34(10,20,30))
130
+ end
131
+
132
+ def dz35_t1
133
+ x = 10
134
+ y = 20
135
+ z = 30
136
+ a = [x+y+z,x*y*z]
137
+ b = [x+y+z/2.0,x*y*z]
138
+ var_max = a.max()
139
+ var_min = b.min()**2+1
140
+ expected_value = {max: var_max, min:var_min }
141
+ assert(expected: expected_value, actual: Mathsuite.dz35(10,20,30))
142
+ end
143
+
144
+ def dz36_t1
145
+ expected_value = {a_Less_b_Less_c: true}
146
+ assert(expected: expected_value, actual: Mathsuite.dz36(10,20,30))
147
+ end
148
+
149
+ def dz37_t1
150
+ expected_value = [900,400,100]
151
+ assert(expected: expected_value, actual: Mathsuite.dz37(30,20,10))
152
+ end
153
+
154
+ def dz38_t1
155
+ expected_value = {z: 30}
156
+ assert(expected: expected_value, actual: Mathsuite.dz38(50,20))
157
+ end
158
+
159
+ def dz39_t1
160
+ expected_value = {z: [50,100]}
161
+ assert(expected: expected_value, actual: Mathsuite.dz39(50,100))
162
+ end
163
+
164
+ def dz40_t1
165
+ expected_value = {result: [0,30]}
166
+ assert(expected: expected_value, actual: Mathsuite.dz40(10,30))
167
+ end
168
+
169
+ def dz41_t1
170
+ expected_value = {res: [2]}
171
+ assert(expected: expected_value, actual: Mathsuite.dz41(1,2,3))
172
+ end
173
+
174
+ def dz42_t1
175
+ expected_value = {res: [15,400]}
176
+ assert(expected: expected_value, actual: Mathsuite.dz42(10,20))
177
+ end
178
+
179
+ def dz43_t1
180
+ expected_value = {res: [4,9,25]}
181
+ assert(expected: expected_value, actual: Mathsuite.dz43(2,3,5))
182
+ end
183
+
184
+ def dz77_t1
185
+ expected_value = {n2: 32, fact: 120}
186
+ assert(expected: expected_value, actual: Mathsuite.dz77(5))
187
+ end
188
+
189
+ def dz196_t1
190
+ expected_value = {:arB=>[10, 22, 12, 26, 14, 30, 16, 34, 18, 38, 20, 42, 22, 46, 24, 50, 26, 54, 28, 58, 30, 62, 32,
191
+ 66, 34, 70, 36, 74, 38, 78, 40, 82, 42, 86, 44, 90, 46, 94, 48, 98, 50, 102, 52, 106, 54,
192
+ 110, 56, 114, 58, 118]}
193
+ assert(expected: expected_value, actual: Mathsuite.dz196())
194
+ end
195
+
196
+ def dz200_t1
197
+ expected_value = 9
198
+ assert(expected: expected_value, actual: Mathsuite.dz200(10,20))
199
+ end
200
+
201
+ def dz204_t1
202
+ expected_value = {:score=>12.5}
203
+ assert(expected: expected_value, actual: Mathsuite.dz204(20))
204
+ end
205
+
206
+ def dz207_t1
207
+ str = "59094715"
208
+ expected_value = {res: "99471" }
209
+ assert(expected: expected_value, actual: Mathsuite.dz207(str))
210
+ end
211
+
212
+ def dz224_t1
213
+ expected_value = {:res=>[1, 3, 37, 111]}
214
+ assert(expected: expected_value, actual: Mathsuite.dz224(111))
215
+ end
216
+
217
+ def dz225_t1
218
+ expected_value = {:res=>[25]}
219
+ assert(expected: expected_value, actual: Mathsuite.dz225(625))
220
+ end
221
+
222
+ def dz251_t1
223
+ str = "xkgiuxytuxgxgjkhkx"
224
+ expected_value = {:res=>5}
225
+ assert(expected: expected_value, actual: Mathsuite.dz251(str))
226
+ end
227
+
228
+ def dz258_t1
229
+ str = "qrabcdceyrejtabcdasryt"
230
+ char1 = "abcd"
231
+ expected_value = {:res=>"qreyrejtsryt"}
232
+ assert(expected: expected_value, actual: Mathsuite.dz258(str,char1))
233
+ end
234
+
235
+ def dz259_t1
236
+ str = "ge*t*s.*c*h**o*m*p"
237
+ char1 = "*"
238
+ expected_value = {:res=>"ggeettss..cchhoommpp"}
239
+ assert(expected: expected_value, actual: Mathsuite.dz259(str,char1))
240
+ end
241
+
242
+ def dz330_t1
243
+ expected_value = {:res_perfect_num=>[1]}
244
+ assert(expected: expected_value, actual: Mathsuite.dz330(1000))
245
+ end
246
+
247
+ def dz331_t1
248
+ expected_value = {:res_num=>[[2, 10, 14], [2, 14, 10], [10, 2, 14], [10, 10, 10], [10, 14, 2], [14, 2, 10], [14, 10, 2]]}
249
+ assert(expected: expected_value, actual: Mathsuite.dz331(300))
250
+ end
251
+
252
+ def dz332_t1
253
+ expected_value = {:res=>[[1, 1, 7, 7], [1, 3, 3, 9], [1, 3, 9, 3], [1, 5, 5, 7], [1, 5, 7, 5], [1, 7, 1, 7], [1, 7, 5, 5],
254
+ [1, 7, 7, 1], [1, 9, 3, 3], [2, 4, 4, 8], [2, 4, 8, 4], [2, 8, 4, 4], [3, 1, 3, 9], [3, 1, 9, 3],
255
+ [3, 3, 1, 9], [3, 3, 9, 1], [3, 9, 1, 3], [3, 9, 3, 1], [4, 2, 4, 8], [4, 2, 8, 4], [4, 4, 2, 8],
256
+ [4, 4, 8, 2], [4, 8, 2, 4], [4, 8, 4, 2], [5, 1, 5, 7], [5, 1, 7, 5], [5, 5, 1, 7], [5, 5, 5, 5],
257
+ [5, 5, 7, 1], [5, 7, 1, 5], [5, 7, 5, 1], [7, 1, 1, 7], [7, 1, 5, 5], [7, 1, 7, 1], [7, 5, 1, 5],
258
+ [7, 5, 5, 1], [7, 7, 1, 1], [8, 2, 4, 4], [8, 4, 2, 4], [8, 4, 4, 2], [9, 1, 3, 3], [9, 3, 1, 3],
259
+ [9, 3, 3, 1]]}
260
+ assert(expected: expected_value, actual: Mathsuite.dz332(100))
261
+ end
262
+
263
+ def dz347_t1
264
+ ar = [3,4,5,1,6,7,8,19]
265
+ expected_value = {:numbers=>[2, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]}
266
+ assert(expected: expected_value, actual: Mathsuite.dz347(ar))
267
+ end
268
+
269
+ def dz434_t1
270
+ aarray = [3,4,5,21,6,7,8,19]
271
+ barray = [31,4,5,1,6,7,8,19]
272
+ expected_value = {:ares=>[3, 4, 5, 21, 0.5, 0.5, 0.5, 0.5], :bres=>[31, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]}
273
+ assert(expected: expected_value, actual: Mathsuite.dz434(aarray,barray))
274
+ end
275
+
276
+ def dz435_t1
277
+ aarray = [3,4,5,21,6,7,8,19]
278
+ barray = [31,4,5,1,6,7,8,19]
279
+ expected_value = {:aarr=>[3, 4, 5, 21, 6, 7, 8, 19], :barr=>[31, 4, 5, 1, 6, 7, 8, 19]}
280
+ assert(expected: expected_value, actual: Mathsuite.dz435(aarray,barray,4))
281
+ end
282
+
283
+ def dz462_t1
284
+ expected_value = {is_a_letter?: true }
285
+ assert(expected: expected_value, actual: Mathsuite.dz462("g"))
286
+ end
287
+
288
+ def dz468_t1
289
+ str1 = "Hello world!"
290
+ str2 = "World hello"
291
+ expected_value = {:sym=>"o", :index=>4}
292
+ assert(expected: expected_value, actual: Mathsuite.dz468(str1,str2))
293
+ end
294
+
295
+ def dz469_t1
296
+ str1 = "Hello world good morning!"
297
+ expected_value = "Hello world good morning!"
298
+ assert(expected: expected_value, actual: Mathsuite.dz469(str1, 25))
299
+ end
300
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mathsuite_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Metelap Vlad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mathtestsuite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: This gem will help you to solve Abramov book math tasks.
28
+ email: vmetww@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE.txt
34
+ - README.md
35
+ - Rakefile
36
+ - lib/mathsuite.rb
37
+ - mathsuite.gemspec
38
+ - test/spec.rb
39
+ homepage: https://github.com/westnick2/mathsuite
40
+ licenses:
41
+ - GPL-2.0
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.7.7
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Solving Abramov book math tasks.
63
+ test_files:
64
+ - test/spec.rb