Okay, so I found another challenge I could do, this time on RosettaCode which deals with file I/O in Ruby.
Basically, there’s a 10,000 line log file to parse and gather some data from it.
This one was really, really simple and took about 5 minutes to do.
license_out = 0
record_out = 0
record_times = []
File.open("licenselog.txt").each do |line|
if line.include?("OUT")
license_out += 1
else
license_out -= 1
end
if license_out > record_out
record_out = license_out
record_times << line.split(" ")[3]
end
end
puts "Maximum licenses out: #{record_out} at the following times: "
puts record_times.join("\n")