Created
May 17, 2015 13:32
-
-
Save Aduciicba/959aa26d3b9ea0cffb21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Road | |
attr_accessor :low_bound, | |
:high_bound, | |
:transport_count, | |
:road_id | |
end | |
file = File.open('F:/input.txt', 'r') | |
i = 0 | |
road_count = file.readline.to_i; | |
arr = Array.new | |
for i in (1..road_count) | |
line = file.readline.to_s | |
r = Road.new() | |
r.road_id = i | |
bound_arr = line.to_s.split(' ') | |
r.low_bound = bound_arr[0] | |
r.high_bound = bound_arr[1] | |
arr << r | |
end | |
file.readline(); | |
transp_str = file.readline().to_s + ' '; | |
start_pos = 0; | |
while start_pos < transp_str.length | |
# хочу как-то так счетчик накопить | |
arr[transp_str[start_pos..transp_str.index(' ', start_pos)].to_i].transport_count += 1 | |
start_pos = transp_str.index(' ', start_pos) + 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment