We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 652acaa commit 383bb52Copy full SHA for 383bb52
1 file changed
horse_racing.rb
@@ -1,23 +1,18 @@
1
# Solution for https://www.codingame.com/ide/puzzle/horse-racing-duals
2
class HorseRacing
3
- attr_accessor :horses_number
+ attr_accessor :horses_count
4
5
def initialize
6
- @horses_number = gets.to_i
+ @horses_count = gets.to_i
7
end
8
9
def find_difference
10
- strenghts = init_strenghts
11
- strenghts.each_cons(2).map { |a, b| (b - a).abs }.min
+ strengths = init_strengths
+ strengths.each_cons(2).map { |a, b| (b - a).abs }.min
12
13
14
- def init_strenghts
15
- strenghts_array = []
16
- horses_number.times do
17
- horse_strenght = gets.to_i
18
- strenghts_array << horse_strenght
19
- end
20
- strenghts_array.sort
+ def init_strengths
+ horses_count.times.each_with_object([]) { |_, result| result << gets.to_i }.sort
21
22
23
def start
0 commit comments