module MathTasks
lib MathTasks
Public Class Methods
task_01(x:,y:)
click to toggle source
# File lib/MathTasks.rb, line 4 def task_01(x:,y:) { summ: x + y, diff: x - y, comp: x * y } end
task_02(x:, y:)
click to toggle source
task 2
# File lib/MathTasks.rb, line 10 def task_02(x:, y:) { result: (x.abs - y.abs) / (1 + (x * y).abs).to_f } end
task_03(range:)
click to toggle source
task 3
# File lib/MathTasks.rb, line 14 def task_03(range:) { size: range**3, square: range**2 } end
task_04(x:, y:)
click to toggle source
task 4
# File lib/MathTasks.rb, line 19 def task_04(x:, y:) { average_arithmetic_value: (x + y) / 2, average_geometric_value: Math.sqrt(x * y) } end
task_05(x:, y:)
click to toggle source
task 5
# File lib/MathTasks.rb, line 24 def task_05(x:, y:) { average_arithmetic_value: (x + y) / 2, average_geometric_value: Math.sqrt(x.abs * y.abs) } end
task_06(leg_x:, leg_y:)
click to toggle source
task 6
# File lib/MathTasks.rb, line 29 def task_06(leg_x:, leg_y:) { hypotenuse: Math.sqrt(leg_x**2 + leg_y**2), square: (leg_x * leg_y) / 2 } end
task_10(mass:, height:)
click to toggle source
task 10
# File lib/MathTasks.rb, line 34 def task_10(mass:, height:) { time: Math.sqrt((2*height)/mass) } end
task_12(length:)
click to toggle source
task 12
# File lib/MathTasks.rb, line 38 def task_12(length:) {square: (Math.sqrt(3) / 4 * length**2).round(3) } end
task_13(length:)
click to toggle source
task 13
# File lib/MathTasks.rb, line 42 def task_13(length:) { result: 2*Math::PI*Math.sqrt(length/9) } end
task_16(length:)
click to toggle source
task 16
# File lib/MathTasks.rb, line 46 def task_16(length:) { result: ((length / 2 / Math::PI)**2 * Math::PI).round(3) } end
task_17(radius:)
click to toggle source
task 17
# File lib/MathTasks.rb, line 50 def task_17(radius:) { result: radius > 20 ? (radius**2 * Math::PI - 20**2 * Math::PI).round(3) : false } end
task_24(x_1:, x_2:, y_1:, y_2:)
click to toggle source
task 24
# File lib/MathTasks.rb, line 54 def task_24(x_1:, x_2:, y_1:, y_2:) { result: Math.sqrt((x_2 - x_1)**2 + (y_2 - y_1)**2) } end
task_33(x:, y:)
click to toggle source
task 33
# File lib/MathTasks.rb, line 58 def task_33(x:, y:) { result: [x, y].min } end
task_38(x:, y:)
click to toggle source
task 38
# File lib/MathTasks.rb, line 62 def task_38(x:, y:) { result: x > y ? x - y : y - x + 1 } end
task_39(x:, y:)
click to toggle source
task 39
# File lib/MathTasks.rb, line 66 def task_39(x:, y:) { reuslt: x > y ? x : [x, y] } end
task_40(x:, y:)
click to toggle source
task 40
# File lib/MathTasks.rb, line 70 def task_40(x:, y:) result = x = 0 if x <= y { result: result } end
task_41(x:, y:, z:)
click to toggle source
task 41
# File lib/MathTasks.rb, line 75 def task_41(x:, y:, z:) { interval_x: case x when 1..3 then x end, interval_y: case y when 1..3 then y end, interval_z: case z when 1..3 then z end } end
task_43(x:, y:, z:)
click to toggle source
task 43
# File lib/MathTasks.rb, line 81 def task_43(x:, y:, z:) { interval_x: case x when x > 0 then x*x end, interval_y: case y when y > 0 then y*y end, interval_z: case z when z > 0 then z*z end } end
task_62(number:)
click to toggle source
task 62
# File lib/MathTasks.rb, line 87 def task_62(number:) { result: number.even? } end