geekhub_tasks 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/geekhub_tasks.rb +447 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c07730095cdcb838fcaa77fae03e825512bd8eb7fc77bc38e074a78b98b0e9
4
- data.tar.gz: ae215106cc2651c0205230a23a090f6561e4c5368f674edfbb4631079289e2eb
3
+ metadata.gz: '0459718112773aa2b58adbab89ad52333bba7744b8ed74804fdc9313980fe6ed'
4
+ data.tar.gz: 53d91e9b829096401bc4422c1a144dbeb4a60e4c8168c4ecfb0e391704561358
5
5
  SHA512:
6
- metadata.gz: 9f03eb2205c906751c1d81f90da8da3ff0a25cd6fe7f3a2f7a0eee2b4b3c621d53ddbc1fbb763e97d0b63a1adbdc375363542eb4c45a68a2a82bdf3947dd5e76
7
- data.tar.gz: 4611612b457295f98a6ab1f51110866f43fcadaa246e5a2f62bd3a55ff81304b3618344eecc7d946427eb1d06230495b41461313cfd01feb09399b2ac23c2a22
6
+ metadata.gz: 9b691b9d47a3361bbefa146b0f614c459a2cc413770fe45f5d0f8b8b4e9b5a417f9cca67f22bcf27be38fae127ff18199d2dbe6822cf4a89e64bb72edd73bce1
7
+ data.tar.gz: 04e49217b223fb601921a320ac0fb2e387f146934a35e976b06b2f636b435f29182e9fcbfcc69a3fd577a3e91d170a54d9cfa87ceb50547fe7b9898dc4d49028
data/lib/geekhub_tasks.rb CHANGED
@@ -1,5 +1,449 @@
1
1
  class GeekHubTasks
2
- def triangle
3
- return 4
2
+
3
+ def self.triangle(a, b)
4
+ hypotenuse = Math.sqrt( ( a**2 ) + ( b**2 ) ).round(2)
5
+ area = ( a * b )/2
6
+ { hypotenuse: hypotenuse, area: area }
7
+ end
8
+
9
+ def self.average(a, b)
10
+ average_ariphmetic = ( a + b )/2
11
+ average_geometric = Math.sqrt( a * b ).round(1)
12
+ { average_ariphmetic: average_ariphmetic, average_geometric: average_geometric }
13
+ end
14
+
15
+ def self.time(h)
16
+ t = Math.sqrt( 2 * ( h/9.8) )
17
+ { t: t }
18
+ end
19
+
20
+ def self.period(l)
21
+ t = ( 2 * Math::PI * (l / 9.8 ) ).round(2)
22
+ { t: t }
23
+ end
24
+
25
+ def self.area_circle(l)
26
+ s = ( (l ** 2) / 4 * Math::PI ).round(2)
27
+ { s: s }
28
+ end
29
+
30
+ def self.sides_triangle(a_1, b_1, r)
31
+ c_1 = ( 180 - ( a_1 + b_1 ) )
32
+ a = 2 * r * Math.sin(a_1 * ( Math::PI/180 ) ).round(2)
33
+ b = 2 * r * Math.sin(b_1 * ( Math::PI/180 ) ).round(2)
34
+ c = 2 * r * Math.sin(c_1.to_i * ( Math::PI/180 ) ).round(2)
35
+ { a: a, b: b, c:c }
36
+ end
37
+
38
+ def self.arithmetic_progression(a, d, n)
39
+ s = ( 2 * a + ( n - 1 ) * d ) * n/2
40
+ { s: s }
41
+ end
42
+
43
+ def self.distance_between_two_points(x_1, x_2, y_1, y_2)
44
+ point_1 = (x_2 - x_1)
45
+ point_2 = (y_2 - y_1)
46
+ s = Math.sqrt(point_1.to_i**2 + point_2.to_i**2).round(2)
47
+ { s: s }
48
+ end
49
+
50
+ def self.mix(v_1, t_1, v_2, t_2)
51
+ z = v_1 + v_2
52
+ t = ( ( v_1 * t_1 ) + ( v_2 * t_2 ) )/z.to_i
53
+ { v: z,
54
+ t: t }
55
+ end
56
+
57
+ def self.triangle_area(a)
58
+ s = ( a**2 ) * (Math.sqrt(3)/4).round(2)
59
+ { s: s }
60
+ end
61
+
62
+ def self.trapezium(a, b, c)
63
+ if a < b
64
+ puts "Mistake..b can't be greater than a"
65
+ end
66
+ x = ( ( ( a - b )/2 ) * Math.tan(c) ).round(2)
67
+ s = ( ( a + b ) * x.to_i)/2
68
+ { h: x,
69
+ s: s }
70
+ end
71
+
72
+ def self.equality(a, b, c)
73
+ if a < b && b < c
74
+ p = "Equality is fulfilled"
75
+ else
76
+ p = "We have trouble with equality"
77
+ end
78
+ { :p => p }
79
+ end
80
+
81
+ def self.x_or_y(x, y)
82
+ if x > y
83
+ z = x - y
84
+ else
85
+ z = y - x + 1
86
+ end
87
+ { z: z }
88
+ end
89
+
90
+ def self.a_or_both(a, b)
91
+ if a > b
92
+ p = "First item"
93
+ else
94
+ p = "Both items"
95
+ end
96
+ { :p => p }
97
+ end
98
+
99
+ def self.even_number(n)
100
+ if n % 2 == 0
101
+ p = "Number is even"
102
+ else
103
+ p = "Sorry,number isn't even"
104
+ end
105
+ { :p => p}
106
+ end
107
+
108
+ def self.check(a, b, r, z)
109
+ ab = a % b
110
+ if ab == r || ab == z
111
+ s = "Really,the remainder is set to the given numbers"
112
+ else
113
+ s = "No,the remainder is no set to the given numbers"
114
+ end
115
+ { :s => s }
116
+ end
117
+
118
+ def self.number_of_hundreds(n)
119
+ num = n / 100
120
+ if n > 99
121
+ s = 1
122
+ else
123
+ s = 2
124
+ end
125
+ {s: s}
126
+ end
127
+
128
+ def self.sixty_seven(n)
129
+ x = n.to_s.length # number of digits in number
130
+ z = n.to_s.chars.map { |sum,n| sum = sum.to_i + n.to_i} # display sum
131
+ x = n.to_s.split('')
132
+ y = x.to_a
133
+ f = "Display the first digit " + y[0].to_s # display first digit
134
+ s = "Display the last digit " + y[-1].to_s # display the last digit
135
+ t = "Display the penultimate digit " + y[-2].to_s # dispaly penultimate digit
136
+ { :f => f, :s => s, :t => t}
137
+ end
138
+
139
+ def self.sixty_eight_a(n)
140
+ if n.to_s.reverse == n.to_s
141
+ p = "This number is palindrome"
142
+ else
143
+ p = "This number is'nt palindrome"
144
+ end
145
+ { :p => p }
146
+ end
147
+
148
+ def self.fourty(a, b)
149
+ if a <= b
150
+ p = ("a = 0")
151
+ a = 0
152
+ else
153
+ p = "a > b"
154
+ end
155
+ { :p => p }
156
+ end
157
+
158
+ def self.age(n)
159
+ if n % 10 == 1 && n != 11
160
+ p = " Год "
161
+ elsif n >= 5 && n <= 20
162
+ p = " Лет "
163
+ elsif n % 10 <= 4 && n % 10 > 0
164
+ p = " Годa "
165
+ else
166
+ p = " Лет "
167
+ end
168
+ {:p => p }
169
+ end
170
+
171
+ def self.power(n)
172
+ x = n**2
173
+ { x: x }
174
+ end
175
+
176
+ def self.factor(n)
177
+ x = Math.gamma(n+1)
178
+ { f: x }
179
+ end
180
+
181
+ def self.chs(k, l)
182
+ if k != l
183
+ sol = "k != l"
184
+ #k = ( k + l) && l = ( k + l )
185
+ else
186
+ sol = "k && l = 0"
187
+ #k = 0 && l = 0
188
+ end
189
+ { :sol => sol }
190
+ end
191
+
192
+ def self.sixty_five(n)
193
+ a = n/10
194
+ b = n - a.to_i * 10
195
+ if a**2 == ( a + b )**3
196
+ z = "Yes, n**2 = n(digital**3)"
197
+ else
198
+ z = "No, n**2 != n(digital**3)"
199
+ end
200
+ { :z => z }
201
+ end
202
+
203
+ def self.math1(x, y)
204
+ sum = x + y
205
+ diff = x - y
206
+ comp = x * y
207
+ { sum: sum, diff: diff, comp: comp}
208
+ end
209
+
210
+ def self.powers(m1, m2, r)
211
+ x = (m1 * m2)/(r**2)
212
+ { sol: x }
213
+ end
214
+
215
+ def self.fou_one(a, b, c)
216
+ if a >= 1 && a <= 3
217
+ a = "belong to the gap"
218
+ else
219
+ a = "do not belong to the gap"
220
+ end
221
+
222
+ if b >= 1 && b <= 3
223
+ b = "belong to the gap"
224
+ else
225
+ b = "do not belong to the gap"
226
+ end
227
+
228
+ if c >= 1 && c <= 3
229
+ c = "belong to the gap"
230
+ else
231
+ c = "do not belong to the gap"
232
+ end
233
+ { a: a, b:b, c:c}
234
+ end
235
+
236
+ def self.half_or_double(x, y)
237
+ if x < y
238
+ x = ( x + y ) / 2
239
+ y = ( x + y ) * 2
240
+ else
241
+ y = ( x + y ) / 2
242
+ x = ( x + y ) * 2
243
+ end
244
+ { sol1: x,
245
+ sol2: y }
246
+ end
247
+
248
+ def self.dano(a, b)
249
+ c = ( Math.sqrt( ( b**2 ) - ( a ** 2 ) ) ).round(0)
250
+ r = ( ( a + c - b)/2 ).round(0)
251
+ { c: c,
252
+ r: r }
253
+ end
254
+
255
+ def self.two_tasks(x)
256
+ result_1 = ( 1 - 2 * x + ( 3 * (x**2 ) ) - ( 4 * ( x**3 ) ) )
257
+ result_2 = ( 1 + 2 * x + ( 3 * (x**2 ) ) + ( 4 * ( x**3 ) ) )
258
+ { result_1: result_1, result_2: result_2 }
259
+ end
260
+
261
+ def self.cube(a)
262
+ v = ( a**3 )
263
+ s = ( 6 * ( a**2 ) )
264
+ { v: v, s:s }
265
+ end
266
+
267
+ def self.quadratic_equation(a, b, c)
268
+ d = b * b - 4 * a * c
269
+
270
+ if (d == 0)
271
+ x1 = ( -b/2/a ) && x2 = ( -b/2/a )
272
+ else
273
+ end
274
+
275
+ if (d > 0)
276
+ x1 = ( (-b-Math.sqrt(d))/2/a).round(2)
277
+ x2 = ( (-b+Math.sqrt(d))/2/a).round(2)
278
+ else
279
+ x1 = (-b/2/a) +(Math.sqrt(-d)/2/a).round(2)
280
+ x2 = (-b/2/a) +(-Math.sqrt(-d)/2/a).round(2)
281
+ end
282
+ { x1: x1, x2: x2 }
283
+ end
284
+
285
+ def self.gsub(n)
286
+ n.downcase!
287
+ if n.to_s.gsub!(/!/, ".")
288
+ s = "Your redacted string is #{n}"
289
+ else
290
+ puts "Nothing to do here!"
291
+ end
292
+ puts "Your string is: #{n}"
293
+ { :s => s }
294
+ end
295
+
296
+ def self.string(n)
297
+ puts "Your string before readected: " + "#{n}"
298
+ n.delete! "*"
299
+ str1 = "Your string after readected: #{n}"
300
+ { :str1 => str1 }
301
+ end
302
+
303
+ def self.include_scan(n)
304
+ if n.include? "eeeee"
305
+ s = "Yes, string include 'eeeee' "
306
+ else
307
+ s = "No, string includen't 'eeeee' "
308
+ end
309
+ { :s => s }
310
+ end
311
+
312
+ def self.gsub_include(n)
313
+ if n.to_s.include? "*"
314
+ x = n.gsub(/!/, "-")
315
+ end
316
+ puts "Text before redacted: #{n}"
317
+ z = "Text after redacted: #{x}"
318
+ { :z => z }
319
+ end
320
+
321
+ def self.real(a, b, c, d)
322
+ z = [a ** 2, b ** 2, c ** 2, d ** 2 ]
323
+ if a <= b && b <= c && c <= d
324
+ norm = "Highest number "
325
+ elsif a > b && b > c && c > d
326
+ norm = "Digital in normal"
327
+ else
328
+ norm = "Squares of numbers #{z}"
329
+ end
330
+ { :norm => norm }
331
+ end
332
+
333
+ def self.put(a)
334
+ arr = []
335
+ x = ( 1..a ).select{ |x| arr << x if a % x == 0 }
336
+ { res: arr}
337
+ end
338
+
339
+ def self.fact(m, n)
340
+ n_1 = Math.gamma(n+1)
341
+ m_1 = Math.gamma(m+1)
342
+ m_n = Math.gamma( ( m + n ) + 1 )
343
+ { result: ( n_1 + m_1 )/m_n }
344
+ end
345
+
346
+ def self.positive_power_two(a, b, c)
347
+ if a > 0
348
+ a = a ** 2
349
+ end
350
+ if b > 0
351
+ b = b ** 2
352
+ end
353
+ if c > 0
354
+ c = c ** 2
355
+ end
356
+ { c: c }
357
+ end
358
+
359
+ def self.mosn(x, y)
360
+ max = [x, y].max
361
+ min = [x, y].min
362
+ minmax = [x, y].minmax
363
+ {max: max, min: min, minmax: minmax}
364
+ end
365
+
366
+ def self.temp(b)
367
+
368
+ to_f = ( ( 0..b ).each { |t| return ( t * 1.8 + 32 ).round(2) } )
369
+ { to_f: to_f }
370
+ end
371
+
372
+ def self.rad(r1, r2)
373
+ if r1 < r2
374
+ r = ( Math::PI * ( r1 ** 2) - ( r2 ** 2) ).round(2)
375
+ else
376
+ r = "das"
377
+ end
378
+ { r: r }
379
+ end
380
+
381
+ def self.new(v1, v2, a1, a2, s)
382
+ result = ( (-(v1+v2)+Math.sqrt( ( (v1+v2) ** 2 )+ 2 * ( a1 + a2 ) * s ) )/( a1 + a2 ) ).round(0)
383
+ { result: result }
384
+ end
385
+
386
+ def self.test(n)
387
+ if n.to_s.include?("3")
388
+ p = "Yes,include"
389
+ else
390
+ p = "No"
391
+ end
392
+ { :p => p}
393
+ end
394
+
395
+ def self.children(n)
396
+ z = n.gsub!(/child/, "children")
397
+ { :p => "#{z}" }
398
+ end
399
+
400
+ def self.average2(a, b)
401
+ average_ariphmetic = ( a.abs + b.abs ) / 2
402
+ average_geometric = Math.sqrt( a.abs * b.abs ).round(1)
403
+ { average_ariphmetic: average_ariphmetic, average_geometric: average_geometric }
404
+ end
405
+
406
+ def self.does_it_exist(x, y, z)
407
+ if x + y >= z || x + z >= y || y + z >= x
408
+ s1 = "Triangle exist"
409
+ else
410
+ s2 = "This is not triangle"
411
+ end
412
+
413
+ if x < y
414
+ k = x;
415
+ m = y;
416
+ else
417
+ k = y;
418
+ m = x;
419
+ end
420
+
421
+ if
422
+ m < z
423
+ h = z
424
+ else
425
+ h = m;
426
+ m = z;
427
+ end
428
+
429
+ t1 = h * h
430
+ t2 = k * k + m * m
431
+
432
+ if t1 < t2
433
+ t1 = "This is an angular triangle"
434
+ else
435
+ t2 = "This isn't an angular triangle"
436
+ end
437
+ { rez1: s1, rez2: t2 }
438
+ end
439
+
440
+ def self.defs(a, b)
441
+ x = a.to_i.gcdlcm b.to_i
442
+ if a.to_i == 0 || b.to_i == 0
443
+ p = "Danger!You try division on 0"
444
+ else
445
+ p = "Greatest common divisor"
446
+ end
447
+ { :p => p }
448
+ end
4
449
  end
5
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geekhub_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maks Gostroushko