RosettaCodeData/Task/Text-processing-Max-licenses-in-use/Wren/text-processing-max-licenses-in-use.wren
2023-07-01 13:44:08 -04:00

24 lines
606 B
Text

import "io" for File
var lines = File.read("mlijobs.txt").replace("\r", "").split("\n")
var out = 0
var max = 0
var times = []
for (line in lines) {
if (line.startsWith("License OUT")) {
out = out + 1
if (out >= max) {
var sp = line.split(" ")
if (out > max) {
max = out
times.clear()
}
times.add(sp[3])
}
} else if (line.startsWith("License IN")) {
out = out - 1
}
}
System.print("The maximum licenses that were out = %(max) at time(s):")
System.print(" " + times.join("\n "))