gem_tasks 0.1.0 → 0.3.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/tasks.rb +449 -0
  3. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae2a1620e13f3f48ac1967402dcdea53098ab4f04d43f4863524585e1a168607
4
- data.tar.gz: ca0999094c46be507dabbf7945f7c293b9cbf3af164cece070a861418ee90523
3
+ metadata.gz: d05fe2d10118898b4dbb77f327b4dd8418d57561a5b60b49838d6b217e12b831
4
+ data.tar.gz: 224f3057cc96222ca3d316a1367b5cb018ef3742b917bf5e2bedd3efd1bac2c8
5
5
  SHA512:
6
- metadata.gz: 510809ad90b883fccee1dc57246a48ff1059c08bc245191213bf43b4bc85fb84146efd3eda5488e62477198cfd50446ea4e33e751ea28df6eb4c171ab672b6cc
7
- data.tar.gz: df9a82b1050b4c1c3681a40e5f8372a1c7b93874300346c597ab6fcc1706a36fe8643f6bd8fae72cb7b36f9541e27b0c65f898652238da071b3baff82478ec64
6
+ metadata.gz: 3523fbaed5138948459ca3d7d67691ec0522be43fc8a25d3d08b5aec8e61f5d886aee7b3edb235d14c61ef3d75e450e19c5857fc1d3e742ad6bf2e1fd686c761
7
+ data.tar.gz: fd3f1ae9104413e5d8b87ba3adea9a13cf28b7af6fc25ce47fdf2e1869438e44b0cd431556685ddd1405aa036850c5a98a544cc9c977735f459e0bf9906f9fe8
data/lib/tasks.rb ADDED
@@ -0,0 +1,449 @@
1
+ module Tasks
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
449
+ end
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-04 00:00:00.000000000 Z
11
+ date: 2018-11-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Much longer explanation of the example!
13
+ description: Special gem for Ruby practice
14
14
  email: makshostroyshko@gmail.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
- files: []
19
- homepage:
18
+ files:
19
+ - lib/tasks.rb
20
+ homepage: https://github.com/MaksGostroushko/Gem_Tasks
20
21
  licenses:
21
22
  - MIT
22
23
  metadata: {}