Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import strutils
var
curOut = 0
maxOut = -1
maxTimes = newSeq[string]()
for job in lines "mlijobs.txt":
if "OUT" in job: inc curOut else: dec curOut
if curOut > maxOut:
maxOut = curOut
maxTimes = @[]
if curOut == maxOut:
maxTimes.add job.split[3]
echo "Maximum simultaneous license use is ",maxOut," at the following times:"
for i in maxTimes: echo " ",i

View file

@ -0,0 +1,34 @@
constant fn = open("mlijobs.txt", "r")
integer maxout = 0, jobnumber
sequence jobs = {}, maxtime, scanres
string inout, jobtime
object line
while 1 do
line = gets(fn)
if atom(line) then exit end if
scanres = scanf(line,"License %s @ %s for job %d\n")
if length(scanres)!=1 then
printf(1,"error scanning line: %s\n",{line})
{} = wait_key()
abort(0)
end if
{{inout,jobtime,jobnumber}} = scanres
if inout="OUT" then
jobs &= jobnumber
if length(jobs)>maxout then
maxout = length(jobs)
maxtime = {jobtime}
elsif length(jobs)=maxout then
maxtime = append(maxtime, jobtime)
end if
else
jobs[find(jobnumber,jobs)] = jobs[$]
jobs = jobs[1..$-1]
end if
end while
close(fn)
printf(1, "Maximum simultaneous license use is %d at the following times:\n", maxout)
for i = 1 to length(maxtime) do
printf(1, "%s\n", {maxtime[i]})
end for

View file

@ -0,0 +1,17 @@
var out = 0;
var max_out = -1;
var max_times = [];
ARGF.each { |line|
out += (line ~~ /OUT/ ? 1 : -1);
out > max_out && (
max_out = out;
max_times = [];
);
out == max_out && (
max_times << line.split(' ')[3];
);
}
say "Maximum simultaneous license use is #{max_out} at the following times:";
max_times.each {|t| " #{t}".say };

View file

@ -0,0 +1,22 @@
# Input: an array of strings
def max_licenses_in_use:
# state: [in_use = 0, max_in_use = -1, max_in_use_at = [] ]
reduce .[] as $line
([0, -1, [] ];
($line|split(" ")) as $line
| if $line[1] == "OUT" then
.[0] += 1 # in_use++;
| if .[0] > .[1] # (in_use > max_in_use)
then .[1] = .[0] # max_in_use = in_use
| .[2] = [$line[3]] # max_in_use_at = [$line[3]]
elif .[0] == .[1] # (in_use == max_in_use)
then .[2] += [$line[3]] # max_in_use_at << $line[3]
else .
end
elif $line[1] == "IN" then .[0] -= 1 # in_use--
else .
end )
| "Max licenses out: \(.[1]) at:\n \(.[2]|join("\n "))" ;
# The file is read in as a single string and so must be split at newlines:
split("\n") | max_licenses_in_use