MathTasks 1.0.0

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/lib/MathTasks.rb +91 -0
  5. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 346bf7663f85e7d323aea8acf2468f2c974e6267f4302a176b8de2ff7be6c4bd
4
+ data.tar.gz: 954cd7d581f9fe0db53c00a87cf8a80031d0a29b0862a50c0f67542b7c2f7e51
5
+ SHA512:
6
+ metadata.gz: d58fcc0af24103b7a1869702e7b9fad20bf1e00859c48883279293a5791fe224f2ffb06eb7c42cbfd574c4502d77cc39158f4e06b86f2a85d2a9a49f2503cb78
7
+ data.tar.gz: 3a41bc92f28c6abcf19c233bf89abdb6d8f7988e6b15d11bbf8ee3aad68ae5c0d76ac274845940cce2add6cf891a0483774c0c1f630f824fb9541a1e2f3e1761
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ usage.rb
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # Gemfile
2
+ source 'https://rubygems.org'
3
+ ruby '2.5.3'
4
+
@@ -0,0 +1,91 @@
1
+ # lib MathTasks
2
+ module MathTasks
3
+ class << self
4
+ def task_01(x:,y:)
5
+ { summ: x + y,
6
+ diff: x - y,
7
+ comp: x * y }
8
+ end
9
+ #task 2
10
+ def task_02(x:, y:)
11
+ { result: (x.abs - y.abs) / (1 + (x * y).abs).to_f }
12
+ end
13
+ #task 3
14
+ def task_03(range:)
15
+ { size: range**3,
16
+ square: range**2 }
17
+ end
18
+ #task 4
19
+ def task_04(x:, y:)
20
+ { average_arithmetic_value: (x + y) / 2,
21
+ average_geometric_value: Math.sqrt(x * y) }
22
+ end
23
+ #task 5
24
+ def task_05(x:, y:)
25
+ { average_arithmetic_value: (x + y) / 2,
26
+ average_geometric_value: Math.sqrt(x.abs * y.abs) }
27
+ end
28
+ #task 6
29
+ def task_06(leg_x:, leg_y:)
30
+ { hypotenuse: Math.sqrt(leg_x**2 + leg_y**2),
31
+ square: (leg_x * leg_y) / 2 }
32
+ end
33
+ #task 10
34
+ def task_10(mass:, height:)
35
+ { time: Math.sqrt((2*height)/mass) }
36
+ end
37
+ #task 12
38
+ def task_12(length:)
39
+ {square: (Math.sqrt(3) / 4 * length**2).round(3) }
40
+ end
41
+ #task 13
42
+ def task_13(length:)
43
+ { result: 2*Math::PI*Math.sqrt(length/9) }
44
+ end
45
+ #task 16
46
+ def task_16(length:)
47
+ { result: ((length / 2 / Math::PI)**2 * Math::PI).round(3) }
48
+ end
49
+ #task 17
50
+ def task_17(radius:)
51
+ { result: radius > 20 ? (radius**2 * Math::PI - 20**2 * Math::PI).round(3) : false }
52
+ end
53
+ #task 24
54
+ def task_24(x_1:, x_2:, y_1:, y_2:)
55
+ { result: Math.sqrt((x_2 - x_1)**2 + (y_2 - y_1)**2) }
56
+ end
57
+ #task 33
58
+ def task_33(x:, y:)
59
+ { result: [x, y].min }
60
+ end
61
+ #task 38
62
+ def task_38(x:, y:)
63
+ { result: x > y ? x - y : y - x + 1 }
64
+ end
65
+ #task 39
66
+ def task_39(x:, y:)
67
+ { reuslt: x > y ? x : [x, y] }
68
+ end
69
+ #task 40
70
+ def task_40(x:, y:)
71
+ result = x = 0 if x <= y
72
+ { result: result }
73
+ end
74
+ #task 41
75
+ def task_41(x:, y:, z:)
76
+ { interval_x: case x when 1..3 then x end,
77
+ interval_y: case y when 1..3 then y end,
78
+ interval_z: case z when 1..3 then z end }
79
+ end
80
+ #task 43
81
+ def task_43(x:, y:, z:)
82
+ { interval_x: case x when x > 0 then x*x end,
83
+ interval_y: case y when y > 0 then y*y end,
84
+ interval_z: case z when z > 0 then z*z end }
85
+ end
86
+ #task 62
87
+ def task_62(number:)
88
+ { result: number.even? }
89
+ end
90
+ end
91
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MathTasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Bondar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Homework GeekHub
14
+ email: dimkawp@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - Gemfile
21
+ - lib/MathTasks.rb
22
+ homepage: https://github.com/dimkawp-2/my_math_task_gem
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.7
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Math tasks
46
+ test_files: []