Class: Feature
- Inherits:
-
Object
- Object
- Feature
- Defined in:
- lib/feature.rb
Instance Method Summary collapse
- #a_less_b_less_c(num_a, num_b, num_c) ⇒ Object
- #a_more_eq_b_more_eq_c(num_a, num_b, num_c) ⇒ Object
- #angeles_triangle(side_a, side_b, side_c) ⇒ Object
- #area_circle(circumference) ⇒ Object
- #area_hypot_triangle(first_leg, second_leg) ⇒ Object
- #area_sector(number_arc, radius = 13.7) ⇒ Object
- #area_triangle(side) ⇒ Object
- #average_ar_geo_num(first_number, second_number) ⇒ Object
- #average_ar_num_and_geo_mod(first_number, second_number) ⇒ Object
- #calc_2_equations(num_x) ⇒ Object
- #calc_equation_1_number(number_x) ⇒ Object
- #calc_equation_2_number(num_x, num_y) ⇒ Object
- #calc_number_z(num_x, num_y) ⇒ Object
- #calcul_the_progression ⇒ Object
- #calcul_value_a_b(value_x, value_y, value_z) ⇒ Object
- #comp_x_y_and_output(num_x, num_y) ⇒ Object
- #comp_x_y_or_x_by_0(num_x, num_y) ⇒ Object
- #compound_resistance(first_resistance, second_resistance, third_resistance) ⇒ Object
- #determ_even_numb(number_x) ⇒ Object
- #determ_hund_in_numb(number_n) ⇒ Object
- #determ_remainder_div_r_s(num_a, num_b, num_r, num_s) ⇒ Object
- #dist_between_points(coordinates_x_frt_point, coordinates_y_frt_point, coordinates_x_scnd_point, coordinates_y_scnd_point) ⇒ Object
- #eq_squa_numb_n_cub_sum(number_n) ⇒ Object
- #fall_time(height, constant_g = 9.83) ⇒ Object
- #floor_round_int_numb_x(number_x) ⇒ Object
- #force_of_gravity(first_mass, second_mass, distance, g = 0.000000000067385) ⇒ Object
- #formula_solution(value_x, value_y) ⇒ Object
- #heig_med_bis_and_rad(side_a, side_b, side_c) ⇒ Object
- #incl_sm_lst_frst_lst_b_on_n(num_n) ⇒ Object
- #less_halfsum_more_doubled(num_x, num_y) ⇒ Object
- #max_min_2_number(num_x, num_y) ⇒ Object
- #meeting_time(acceleration_f, acceleration_s, speed_f, speed_s, distance) ⇒ Object
- #min_max_2_equations(num_x, num_y, num_z) ⇒ Object
- #min_max_3_number(num_x, num_y, num_z) ⇒ Object
- #non_negative_number(num_x, num_y, num_z) ⇒ Object
- #number_check(number) ⇒ Object
- #period_of_oscillation(length, constant_g = 9.83) ⇒ Object
- #permtr_area_triangle(coordinates_x_point_a, coordinates_y_point_a, coordinates_x_point_b, coordinates_y_point_b, coordinates_x_point_c, coordinates_y_point_c) ⇒ Object
- #permtr_multicutnik(number_of_corners, radius) ⇒ Object
- #ring_area(inner_radius = 20, outer_radius) ⇒ Object
- #sec_leg_radius_inscr_circle(first_leg, hypotenuse) ⇒ Object
- #sides_triangle(angles_A, angles_B, angles_C, radius) ⇒ Object
- #sum_arith_progression(value_a, value_d, value_n) ⇒ Object
- #sum_diff_product(first_number, second_number) ⇒ Object
- #trapezium_area(greater_base, smaller_base, angle) ⇒ Object
- #value_temp_water(f_volue, f_temperature, s_value, s_temperature) ⇒ Object
- #volume_area_cube(length_of_the_edge) ⇒ Object
Instance Method Details
#a_less_b_less_c(num_a, num_b, num_c) ⇒ Object
224 225 226 |
# File 'lib/feature.rb', line 224 def a_less_b_less_c(num_a, num_b, num_c) (num_a < num_b && num_b < num_c) ? true : false end |
#a_more_eq_b_more_eq_c(num_a, num_b, num_c) ⇒ Object
228 229 230 |
# File 'lib/feature.rb', line 228 def a_more_eq_b_more_eq_c(num_a, num_b, num_c) (num_a >= num_b && num_b >= num_c) ? [num_a * 2, num_b * 2, num_c * 2] : [num_a.abs, num_b.abs, num_c.abs] end |
#angeles_triangle(side_a, side_b, side_c) ⇒ Object
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/feature.rb', line 171 def angeles_triangle (side_a, side_b, side_c) angele_b = ((side_a ** 2 + side_c ** 2) - side_b ** 2) / (2 * side_c * side_a).to_f * 180 angele_c = ((side_a ** 2 + side_b ** 2) - side_c ** 2) / (2 * side_b * side_a).to_f * 180 angele_a = 180 - angele_b + angele_c { angele_a: angele_a.abs.round, angele_b: angele_b.abs.round, angele_c: angele_c.abs.round } end |
#area_circle(circumference) ⇒ Object
91 92 93 94 |
# File 'lib/feature.rb', line 91 def area_circle(circumference) radius = circumference / (2 * Math::PI) Math::PI * radius ** 2 end |
#area_hypot_triangle(first_leg, second_leg) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/feature.rb', line 36 def area_hypot_triangle(first_leg, second_leg) { area: 0.5 * first_leg * second_leg, hypotenuse: Math.sqrt(first_leg ** 2 + second_leg ** 2) } end |
#area_sector(number_arc, radius = 13.7) ⇒ Object
167 168 169 |
# File 'lib/feature.rb', line 167 def area_sector(number_arc, radius = 13.7) area = ((number_arc / 2.to_f) * radius ** 2).round end |
#area_triangle(side) ⇒ Object
69 70 71 |
# File 'lib/feature.rb', line 69 def area_triangle(side) (1 / 2.to_f) * side * Math.sqrt(side ** 2 - side ** 2 / 2) end |
#average_ar_geo_num(first_number, second_number) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/feature.rb', line 22 def average_ar_geo_num(first_number, second_number) { arithmetical: (first_number + second_number) / 2.to_f, geometrical: Math.sqrt(first_number * second_number) } end |
#average_ar_num_and_geo_mod(first_number, second_number) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/feature.rb', line 29 def average_ar_num_and_geo_mod(first_number, second_number) { arithmetical: (first_number + second_number) / 2, geometrical: Math.sqrt(first_number.abs * second_number.abs) } end |
#calc_2_equations(num_x) ⇒ Object
191 192 193 194 195 196 |
# File 'lib/feature.rb', line 191 def calc_2_equations(num_x) { answer1: 1 + num_x * (-2 + num_x * (3 - 4 * num_x)), answer2: 1 + num_x * (2 + num_x * (3 + 4 * num_x)) } end |
#calc_equation_1_number(number_x) ⇒ Object
182 183 184 |
# File 'lib/feature.rb', line 182 def calc_equation_1_number(number_x) 6 + number_x * (-5 + number_x * (4 - 3 * number_x + 2 * (number_x + number_x))) end |
#calc_equation_2_number(num_x, num_y) ⇒ Object
186 187 188 189 |
# File 'lib/feature.rb', line 186 def calc_equation_2_number(num_x, num_y) num_x * (num_x + num_x + num_x - (num_y + num_y) - 7 * num_x + 15) + num_y * (10 - 4 * num_y) + num_x * (num_x + num_x - 3) + 6 end |
#calc_number_z(num_x, num_y) ⇒ Object
232 233 234 |
# File 'lib/feature.rb', line 232 def calc_number_z(num_x, num_y) num_x > num_y ? num_x - num_y : num_y - (num_x + 1) end |
#calcul_the_progression ⇒ Object
307 308 309 310 311 |
# File 'lib/feature.rb', line 307 def calcul_the_progression result = 1 (0.1..10).step(0.1) { |i| result *= 1 + Math.sin(i) } result end |
#calcul_value_a_b(value_x, value_y, value_z) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/feature.rb', line 62 def calcul_value_a_b(value_x, value_y, value_z) { value_a: (2 * Math.cos(value_x - Math::PI / 6)) / (1 / 2 + Math.sin(value_y) ** 2), value_b: 1 + (value_z ** 2 / 3 + value_z ** 2 / 5) } end |
#comp_x_y_and_output(num_x, num_y) ⇒ Object
236 237 238 |
# File 'lib/feature.rb', line 236 def comp_x_y_and_output(num_x, num_y) num_x > num_y ? num_x : [num_x, num_y] end |
#comp_x_y_or_x_by_0(num_x, num_y) ⇒ Object
240 241 242 |
# File 'lib/feature.rb', line 240 def comp_x_y_or_x_by_0(num_x, num_y) num_x <= num_y ? num_x = 0 : [num_x, num_y] end |
#compound_resistance(first_resistance, second_resistance, third_resistance) ⇒ Object
54 55 56 |
# File 'lib/feature.rb', line 54 def compound_resistance(first_resistance, second_resistance, third_resistance) 1 / ((1 / first_resistance.to_f) + (1 / second_resistance.to_f) + (1 / third_resistance.to_f)) end |
#determ_even_numb(number_x) ⇒ Object
265 266 267 |
# File 'lib/feature.rb', line 265 def determ_even_numb(number_x) number_x % 2 == 0 ? true : false end |
#determ_hund_in_numb(number_n) ⇒ Object
278 279 280 |
# File 'lib/feature.rb', line 278 def determ_hund_in_numb(number_n) number_n > 99 ? number_n / 100.to_i : false end |
#determ_remainder_div_r_s(num_a, num_b, num_r, num_s) ⇒ Object
269 270 271 272 273 274 275 276 |
# File 'lib/feature.rb', line 269 def determ_remainder_div_r_s(num_a, num_b, num_r, num_s) remainder = num_a % num_b { remainder_equal_r: remainder == num_r ? true : nil, remainder_equal_s: remainder == num_s ? true : nil, remainder_not_equal_r_or_s: remainder != num_r && remainder != num_s ? true : nil } end |
#dist_between_points(coordinates_x_frt_point, coordinates_y_frt_point, coordinates_x_scnd_point, coordinates_y_scnd_point) ⇒ Object
145 146 147 148 149 |
# File 'lib/feature.rb', line 145 def dist_between_points(coordinates_x_frt_point, coordinates_y_frt_point, coordinates_x_scnd_point, coordinates_y_scnd_point) distance = (Math.sqrt((coordinates_x_scnd_point - coordinates_x_frt_point) ** 2 + (coordinates_y_scnd_point - coordinates_y_frt_point) ** 2)).round end |
#eq_squa_numb_n_cub_sum(number_n) ⇒ Object
282 283 284 285 |
# File 'lib/feature.rb', line 282 def eq_squa_numb_n_cub_sum(number_n) sum = number_n.to_s.split('').map.each {|x| x.to_i}.sum number_n ** 2 == sum ** 3 ? true : false end |
#fall_time(height, constant_g = 9.83) ⇒ Object
58 59 60 |
# File 'lib/feature.rb', line 58 def fall_time(height, constant_g = 9.83) Math.sqrt(2 * height / constant_g) end |
#floor_round_int_numb_x(number_x) ⇒ Object
257 258 259 260 261 262 263 |
# File 'lib/feature.rb', line 257 def floor_round_int_numb_x(number_x) { floor: number_x.floor, round: number_x.round, to_i: number_x.to_i } end |
#force_of_gravity(first_mass, second_mass, distance, g = 0.000000000067385) ⇒ Object
77 78 79 |
# File 'lib/feature.rb', line 77 def force_of_gravity(first_mass, second_mass, distance, g = 0.000000000067385) g * ((first_mass * second_mass) / distance ** 2) end |
#formula_solution(value_x, value_y) ⇒ Object
11 12 13 |
# File 'lib/feature.rb', line 11 def formula_solution(value_x, value_y) (value_x.abs - value_y.abs) / (1 + (value_x * value_y).abs).to_f end |
#heig_med_bis_and_rad(side_a, side_b, side_c) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/feature.rb', line 122 def heig_med_bis_and_rad(side_a, side_b, side_c) semiperimeter = ((side_a + side_b + side_c) / 2).to_f { #length height height_a: calcul_triangle_height(side_a, side_b, side_c, side_a), height_b: calcul_triangle_height(side_a, side_b, side_c, side_b), height_c: calcul_triangle_height(side_a, side_b, side_c, side_c), #length median median_a: calcul_triangle_median(side_b, side_c, side_a), median_b: calcul_triangle_median(side_a, side_c, side_b), median_c: calcul_triangle_median(side_a, side_b, side_c), #length bisector bisector_a: calcul_triangle_bisector(side_b, side_c, side_a), bisector_b: calcul_triangle_bisector(side_a, side_c, side_b), bisector_c: calcul_triangle_bisector(side_a, side_b, side_c), #radius circumscribed inscribed circle radius_circumscribed: (side_a * side_b * side_c / (4 * Math.sqrt(semiperimeter * (semiperimeter - side_a) * (semiperimeter - side_b) * (semiperimeter - side_c)))).round(1), radius_inscribed: Math.sqrt((semiperimeter - side_a) * (semiperimeter - side_b) * (semiperimeter - side_c) / semiperimeter).round(1) } end |
#incl_sm_lst_frst_lst_b_on_n(num_n) ⇒ Object
287 288 289 290 291 292 293 294 295 |
# File 'lib/feature.rb', line 287 def incl_sm_lst_frst_lst_b_on_n(num_n) { including: num_n.to_s.split("").length, sum: num_n.to_s.split("").map.each {|x| x.to_i}.sum, last: num_n.to_s.split("").last.to_i, first: num_n.to_s.split("").first.to_i, last_but_one: num_n.to_s[-2].to_i } end |
#less_halfsum_more_doubled(num_x, num_y) ⇒ Object
244 245 246 247 |
# File 'lib/feature.rb', line 244 def less_halfsum_more_doubled(num_x, num_y) num_x > num_y ? [x = (num_x + num_y) / 2.to_f, y = num_x * num_y * 2] : [y = (num_x + num_y) / 2.to_f, x = (num_x * num_y) * 2 ] end |
#max_min_2_number(num_x, num_y) ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/feature.rb', line 198 def max_min_2_number(num_x, num_y) { max: [num_x, num_y].max, min: [num_x, num_y].min, max_min: [num_x, num_y].minmax.reverse } end |
#meeting_time(acceleration_f, acceleration_s, speed_f, speed_s, distance) ⇒ Object
108 109 110 111 112 |
# File 'lib/feature.rb', line 108 def meeting_time(acceleration_f, acceleration_s, speed_f, speed_s, distance) average_acceleration = (acceleration_f + acceleration_s) / 2 average_speed = speed_f + speed_s (-average_speed + Math.sqrt(-average_speed ** 2 + (4 * distance * average_acceleration))) / (2 * average_acceleration) end |
#min_max_2_equations(num_x, num_y, num_z) ⇒ Object
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/feature.rb', line 213 def min_max_2_equations(num_x, num_y, num_z) sum = num_x + num_y + num_z product = num_x * num_y * num_z new_sum = ((sum / 2.to_f) ** 2) + 1 new_product = product ** 2 + 1 { max: sum > product ? sum : product, min: new_sum < new_product ? new_sum : new_product } end |
#min_max_3_number(num_x, num_y, num_z) ⇒ Object
206 207 208 209 210 211 |
# File 'lib/feature.rb', line 206 def min_max_3_number(num_x, num_y, num_z) { max: [num_x, num_y, num_z].max, min_max: [num_x, num_y, num_z].minmax } end |
#non_negative_number(num_x, num_y, num_z) ⇒ Object
249 250 251 252 253 254 255 |
# File 'lib/feature.rb', line 249 def non_negative_number(num_x, num_y, num_z) { a_more_0: num_x >= 0 ? num_x ** 2 : nil, b_more_0: num_y >= 0 ? num_y ** 2 : nil, c_more_0: num_z >= 0 ? num_z ** 2 : nil } end |
#number_check(number) ⇒ Object
297 298 299 300 301 302 303 304 305 |
# File 'lib/feature.rb', line 297 def number_check(number) { palindrome: number == number.to_s.reverse.to_i ? true : false , three_identical_numbers: (number.to_s.split('').uniq.size == 2 && number != number.to_s.reverse.to_i) ? true : false , numbers_different: number.to_s.split('') == number.to_s.split('').uniq ? true : false } end |
#period_of_oscillation(length, constant_g = 9.83) ⇒ Object
73 74 75 |
# File 'lib/feature.rb', line 73 def period_of_oscillation(length, constant_g = 9.83) 2 * Math::PI * Math.sqrt(length / constant_g) end |
#permtr_area_triangle(coordinates_x_point_a, coordinates_y_point_a, coordinates_x_point_b, coordinates_y_point_b, coordinates_x_point_c, coordinates_y_point_c) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/feature.rb', line 151 def permtr_area_triangle(coordinates_x_point_a, coordinates_y_point_a, coordinates_x_point_b, coordinates_y_point_b, coordinates_x_point_c, coordinates_y_point_c) distance_a = calcuate_distance(coordinates_x_point_b, coordinates_x_point_a, coordinates_y_point_b,coordinates_y_point_a) distance_b = calcuate_distance(coordinates_x_point_b, coordinates_x_point_c, coordinates_y_point_b, coordinates_y_point_c) distance_c = calcuate_distance(coordinates_x_point_c, coordinates_x_point_a, coordinates_y_point_c, coordinates_y_point_a) semiperimeter = ((distance_a + distance_b + distance_c) / 2) { perimeter: distance_a + distance_b + distance_c, area: Math.sqrt(semiperimeter * (semiperimeter - distance_a) * (semiperimeter - distance_b) * (semiperimeter - distance_c)).round } end |
#permtr_multicutnik(number_of_corners, radius) ⇒ Object
50 51 52 |
# File 'lib/feature.rb', line 50 def permtr_multicutnik(number_of_corners, radius) number_of_corners * 2 * radius * Math.sin(Math::PI / number_of_corners) end |
#ring_area(inner_radius = 20, outer_radius) ⇒ Object
96 97 98 |
# File 'lib/feature.rb', line 96 def ring_area(inner_radius = 20, outer_radius) (Math::PI * (inner_radius ** 2 - outer_radius ** 2)).to_i end |
#sec_leg_radius_inscr_circle(first_leg, hypotenuse) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/feature.rb', line 81 def sec_leg_radius_inscr_circle(first_leg, hypotenuse) second_leg = Math.sqrt(hypotenuse ** 2 - first_leg ** 2) triangle_semi_perimeter = 0.5 * (first_leg + hypotenuse + second_leg) { radius: Math.sqrt((triangle_semi_perimeter - first_leg) * (triangle_semi_perimeter - hypotenuse) * (triangle_semi_perimeter - second_leg)) / triangle_semi_perimeter, second_leg: second_leg } end |
#sides_triangle(angles_A, angles_B, angles_C, radius) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/feature.rb', line 100 def sides_triangle(angles_A, angles_B, angles_C, radius) { side_a: calcul_triangle_sides(radius, angles_A), side_b: calcul_triangle_sides(radius, angles_B), side_c: calcul_triangle_sides(radius, angles_C) } end |
#sum_arith_progression(value_a, value_d, value_n) ⇒ Object
114 115 116 |
# File 'lib/feature.rb', line 114 def sum_arith_progression(value_a, value_d, value_n) ((2 * value_a + (value_n - 1) * value_d) / 2) * value_n end |
#sum_diff_product(first_number, second_number) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/feature.rb', line 3 def sum_diff_product(first_number, second_number) { sum: first_number + second_number, diff: first_number - second_number, product: first_number * second_number } end |
#trapezium_area(greater_base, smaller_base, angle) ⇒ Object
118 119 120 |
# File 'lib/feature.rb', line 118 def trapezium_area(greater_base, smaller_base, angle) (((greater_base + smaller_base) / 2) * ((greater_base - smaller_base) / 2) * Math.tan(angle)).to_i end |
#value_temp_water(f_volue, f_temperature, s_value, s_temperature) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/feature.rb', line 43 def value_temp_water(f_volue, f_temperature, s_value, s_temperature) { value: f_volue + s_value, tempetature: ((f_volue * f_temperature) + (s_value * s_temperature)) / (f_volue + s_value).to_f } end |
#volume_area_cube(length_of_the_edge) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/feature.rb', line 15 def volume_area_cube(length_of_the_edge) { volume: length_of_the_edge ** 3, area: 6 * length_of_the_edge ** 2 } end |