Skip to content

Instantly share code, notes, and snippets.

@Aduciicba
Last active August 29, 2015 14:21
Show Gist options
  • Save Aduciicba/a924e023befb442b75dd to your computer and use it in GitHub Desktop.
Save Aduciicba/a924e023befb442b75dd to your computer and use it in GitHub Desktop.
example
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