Text processing/Max licenses in use: Difference between revisions

Content added Content deleted
(Added Julia language)
(Scala contribution added.)
Line 1: Line 1:
{{task|Text processing}}
{{task|Text processing}}


A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.


Assume the software's licensing daemon faithfully records a checkout event when a copy of the software starts and a checkin event when the software finishes to its log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the software starts and a checkin event when the software finishes to its log file.
Line 12: Line 12:


;Task:
;Task:
Save the 10,000 line log file from &nbsp; [http://rosettacode.org/resources/mlijobs.txt <big> here</big>] &nbsp; into a local file, then write a program to scan the file extracting both the maximum licenses that were out at any time, and the time(s) at which this occurs.
Save the 10,000 line log file from [http://rosettacode.org/resources/mlijobs.txt <big>here</big>] into a local file, then write a program to scan the file extracting both the maximum licenses that were out at any time, and the time(s) at which this occurs.


Mirror of log file available as a zip [https://github.com/thundergnat/rc/blob/master/resouces/mlijobs.zip here] (offsite mirror).
Mirror of log file available as a zip [https://github.com/thundergnat/rc/blob/master/resouces/mlijobs.zip here] (offsite mirror).
<br><br>
<br><br>

=={{header|Ada}}==
=={{header|Ada}}==
<lang Ada>-- licenselist.adb --
<lang Ada>-- licenselist.adb --
Line 89: Line 88:
end licenselist;</lang>
end licenselist;</lang>
Output:
Output:
The max. number of licenses out is 99
<pre>
The max. number of licenses out is 99
at these times
at these times
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
[2010-06-06 01:06:07] process terminated successfully (elapsed time: 00.25s)
[2010-06-06 01:06:07] process terminated successfully (elapsed time: 00.25s)

</pre>
=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{trans|C}} note: This specimen retains the original [http://rosettacode.org/mw/index.php?title=Text_processing%2F3&diff=87014&oldid=87011 C] coding style.
{{trans|C}} note: This specimen retains the original [http://rosettacode.org/mw/index.php?title=Text_processing%2F3&diff=87014&oldid=87011 C] coding style.
Line 174: Line 172:
)</lang>
)</lang>
Output:
Output:
Maximum simultaneous license use is 99 at the following times:
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|APL}}==
=={{header|APL}}==
Line 188: Line 184:
mx ← (⎕IO+⍳⍴lu)/⍨lu= max ← ⌈/ lu
mx ← (⎕IO+⍳⍴lu)/⍨lu= max ← ⌈/ lu
⎕ ← 'Maximum simultaneous license use is ' , ' at the following times:' ,⍨ ⍕max ⋄ ⎕←D[mx;]</lang>
⎕ ← 'Maximum simultaneous license use is ' , ' at the following times:' ,⍨ ⍕max ⋄ ⎕←D[mx;]</lang>
<lang apl>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</lang>
2008/10/03_08:40:40


=={{Header|AutoHotkey}}==
=={{Header|AutoHotkey}}==
{{trans|Python}}
{{trans|Python}}
<lang autohotkey>
<lang autohotkey>IfNotExist, mlijobs.txt
IfNotExist, mlijobs.txt
UrlDownloadToFile, http://rosettacode.org/mlijobs.txt, mlijobs.txt
UrlDownloadToFile, http://rosettacode.org/mlijobs.txt, mlijobs.txt


Line 215: Line 210:
}
}


MsgBox Maximum use is %max_out% at:`n`n%max_times%
MsgBox Maximum use is %max_out% at:`n`n%max_times%</lang>
Maximum use is 99 at:
</lang>
<pre>
Maximum use is 99 at:


2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|AWK}}==
=={{header|AWK}}==
Line 242: Line 234:


'''Sample output'''
'''Sample output'''
<pre>The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !</pre>
The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !


On a 2.53MHz machine, these timings were obtained using GNU Awk 4.0.2:
On a 2.53MHz machine, these timings were obtained using GNU Awk 4.0.2:
Line 278: Line 270:
END</lang>
END</lang>
'''Output:'''
'''Output:'''
Maximum licences checked out = 99
<pre>
From 2008/10/03_08:39:34 to 2008/10/03_08:40:40
Maximum licences checked out = 99
From 2008/10/03_08:39:34 to 2008/10/03_08:40:40
</pre>


=={{header|Bracmat}}==
=={{header|Bracmat}}==

<lang bracmat>( 0:?N:?n
<lang bracmat>( 0:?N:?n
& :?Ts
& :?Ts
Line 303: Line 292:
)
)
| out$(!N !Ts)
| out$(!N !Ts)
);
);</lang>
</lang>
Output:
Output:
<pre>99 2008/10/03_08:39:34 2008/10/03_08:40:40</pre>
99 2008/10/03_08:39:34 2008/10/03_08:40:40


=={{header|C}}==
=={{header|C}}==

<lang c>#include <stdio.h>
<lang c>#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
Line 410: Line 397:
munmap(buf, s.st_size);
munmap(buf, s.st_size);
return close(fd);
return close(fd);
}</lang>output<lang>2008/10/03_08:39:34 99
}</lang>output
2008/10/03_08:40:40 99</lang>
2008/10/03_08:39:34 99
2008/10/03_08:40:40 99


=={{header|C++}}==
=={{header|C++}}==
Line 470: Line 458:


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang csharp>
<lang csharp>using System;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
Line 516: Line 503:
}
}
}
}
}</lang>
}
99
</lang>
2008/10/03_08:39:34
<pre>
2008/10/03_08:40:40
99
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


=={{header|Clojure}}==
=={{header|Clojure}}==

<lang clojure>(defn delta [entry]
<lang clojure>(defn delta [entry]
(case (second (re-find #"\ (.*)\ @" entry))
(case (second (re-find #"\ (.*)\ @" entry))
Line 543: Line 526:
(map println times))</lang>
(map println times))</lang>


Maximum simultaneous license use is 99 at the following times:
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|COBOL}}==
=={{header|COBOL}}==
Line 643: Line 624:


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==

{{libheader|CL-PPCRE}}
{{libheader|CL-PPCRE}}

<lang lisp>(defun max-licenses (&optional (logfile "mlijobs.txt"))
<lang lisp>(defun max-licenses (&optional (logfile "mlijobs.txt"))
(with-open-file (log logfile :direction :input)
(with-open-file (log logfile :direction :input)
Line 665: Line 644:
(push time max-log-times)))))))</lang>
(push time max-log-times)))))))</lang>


<pre>> (max-licenses)
> (max-licenses)
Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40.
2008/10/03_08:40:40.
NIL</pre>
NIL

=={{header|D}}==
=={{header|D}}==
<lang d>void main() {
<lang d>void main() {
Line 691: Line 669:
}</lang>
}</lang>
{{out}}
{{out}}
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
"2008/10/03_08:39:34"
"2008/10/03_08:39:34"
"2008/10/03_08:40:40"</pre>
"2008/10/03_08:40:40"


=={{header|E}}==
=={{header|E}}==

{{trans|Python}}
{{trans|Python}}

<lang e>var out := 0
<lang e>var out := 0
var maxOut := 0
var maxOut := 0
Line 723: Line 699:
}</lang>
}</lang>
=={{header|Eiffel}}==
=={{header|Eiffel}}==
<lang Eiffel>
<lang Eiffel>class
class
APPLICATION
APPLICATION


Line 776: Line 751:
data: LIST [STRING]
data: LIST [STRING]


end
end</lang>
</lang>
{{out}}
{{out}}
Max Licences OUT: 99
<pre>
Date: 2008/10/03_08:39:34
Max Licences OUT: 99
Date: 2008/10/03_08:39:34
</pre>


=={{header|Erlang}}==
=={{header|Erlang}}==
<lang Erlang>
<lang Erlang>-module( text_processing_max_licenses ).
-module( text_processing_max_licenses ).


-export( [out_dates_from_file/1, task/0] ).
-export( [out_dates_from_file/1, task/0] ).
Line 813: Line 784:


out_dates_n( N, <<"OUT">> ) -> N + 1;
out_dates_n( N, <<"OUT">> ) -> N + 1;
out_dates_n( N, <<"IN">> ) -> N - 1.
out_dates_n( N, <<"IN">> ) -> N - 1.</lang>
</lang>
{{out}}
{{out}}
12> text_processing_max_licenses:task().
<pre>
Max licenses was 99 at [<<"2008/10/03_08:39:34">>,<<"2008/10/03_08:40:40">>]
12> text_processing_max_licenses:task().
Max licenses was 99 at [<<"2008/10/03_08:39:34">>,<<"2008/10/03_08:40:40">>]
</pre>


=={{header|Euphoria}}==
=={{header|Euphoria}}==
Line 877: Line 845:
printf(1, "%s\n", {maxtime[i]})
printf(1, "%s\n", {maxtime[i]})
end for</lang>
end for</lang>

Output:
Output:
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Factor}}==
=={{header|Factor}}==
Placing the file in resource:work/mlijobs.txt:
Placing the file in resource:work/mlijobs.txt:

<lang factor>USING: kernel sequences splitting math accessors io.encodings.ascii
<lang factor>USING: kernel sequences splitting math accessors io.encodings.ascii
io.files math.parser io ;
io.files math.parser io ;
Line 946: Line 911:


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth>
<lang forth>20 constant date-size
20 constant date-size
create max-dates date-size 100 * allot
create max-dates date-size 100 * allot
variable max-out
variable max-out
Line 979: Line 943:
max-dates count type cr ;
max-dates count type cr ;


main bye
main bye</lang>
</lang>


== {{header|Fortran}} ==
== {{header|Fortran}} ==
{{Works with|Fortran|90 and later}}
{{Works with|Fortran|90 and later}}


<lang fortran>
<lang fortran> PROGRAM MAX_LICENSES
PROGRAM MAX_LICENSES
IMPLICIT NONE
IMPLICIT NONE
Line 1,022: Line 984:
WRITE(*,"(A)") maxtime(1:maxcount)
WRITE(*,"(A)") maxtime(1:maxcount)
END PROGRAM MAX_LICENSES
END PROGRAM MAX_LICENSES</lang>
</lang>
Output
Output
<pre>
Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40

</pre>
=={{header|Gema}}==
=={{header|Gema}}==
Start with ''gema -f licenses.gema mlijobs.txt''
Start with ''gema -f licenses.gema mlijobs.txt''
<lang gema>
<lang gema>@set{count;0};@set{max;0}
@set{count;0};@set{max;0}


License OUT \@ * *\n=@incr{count}@testmax{${count},*}
License OUT \@ * *\n=@incr{count}@testmax{${count},*}
Line 1,041: Line 1,000:
testmax:*,*=@cmpn{${max};$1;@set{max;$1};;}@append{times${count};$2\n}
testmax:*,*=@cmpn{${max};$1;@set{max;$1};;}@append{times${count};$2\n}


report:*,*=Maximum simultaneous license use is * at\n*
report:*,*=Maximum simultaneous license use is * at\n*</lang>
</lang>
Output:
Output:
Maximum simultaneous license use is 99 at
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Go}}==
=={{header|Go}}==
Line 1,112: Line 1,068:
}</lang>
}</lang>
{{out}}
{{out}}
max licenses: 99
<pre>
at:
max licenses: 99
at:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Groovy}}==
=={{header|Groovy}}==
Line 1,148: Line 1,102:


println "Maximum Licenses $max"
println "Maximum Licenses $max"
dates.each { date -> println " $date" }
dates.each { date -> println " $date" }</lang>
</lang>
Output:
Output:
Maximum Licenses 99
<pre>
Maximum Licenses 99
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


== {{header|Haskell}} ==
== {{header|Haskell}} ==
<lang haskell>
<lang haskell>import Data.List
import Data.List


main = do
main = do
Line 1,167: Line 1,117:
mo = maximum cio
mo = maximum cio
putStrLn $ "Maximum simultaneous license use is " ++ show mo ++ " at:"
putStrLn $ "Maximum simultaneous license use is " ++ show mo ++ " at:"
mapM_ (putStrLn . (dt!!)) . elemIndices mo $ cio
mapM_ (putStrLn . (dt!!)) . elemIndices mo $ cio</lang>
</lang>


=={{header|HicEst}}==
=={{header|HicEst}}==
{{incorrect|HicEst}}
We open Licenses.txt in [http://www.HicEst.com/MatrixExplorer.htm MatrixExplorer mode] with 3 columns: IN/OUT, date_time, ID_nr.
We open Licenses.txt in [http://www.HicEst.com/MatrixExplorer.htm MatrixExplorer mode] with 3 columns: IN/OUT, date_time, ID_nr.
This allows to adress single file elements by Licenses(row, column).
This allows to adress single file elements by Licenses(row, column).
Line 1,221: Line 1,171:


And a run of the program:
And a run of the program:
<pre>->ml <mlijobs.txt
->ml <mlijobs.txt
There were 99 licenses out at:
There were 99 licenses out at:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
-></pre>
->



== {{header|J}} ==
== {{header|J}} ==
Line 1,236: Line 1,185:
NB. Output results
NB. Output results
(mx { D) ,~ 'Maximum simultaneous license use is ' , ' at the following times:' ,~ ": {. ,mx { lu</lang>
(mx { D) ,~ 'Maximum simultaneous license use is ' , ' at the following times:' ,~ ": {. ,mx { lu</lang>
<pre>
Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Java}}==
=={{header|Java}}==
Line 1,274: Line 1,221:
}
}
}</lang>
}</lang>
<pre>Max licenses out: 99
Max licenses out: 99
At time(s): [2008/10/03_08:39:34, 2008/10/03_08:40:40]</pre>
At time(s): [2008/10/03_08:39:34, 2008/10/03_08:40:40]


=={{header|JavaScript}}==
=={{header|JavaScript}}==
Line 1,303: Line 1,250:


output:
output:
<pre>Max licenses out: 99
Max licenses out: 99
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
2008/10/03_08:40:40
=={{header|jq}}==
=={{header|jq}}==
{{works with|jq|1.4}}
{{works with|jq|1.4}}
Line 1,344: Line 1,291:
`0:,/"Maximum simultaneous license use is ",$x;
`0:,/"Maximum simultaneous license use is ",$x;
`0:" at the following times:\n";`0:r[;14+!19]</lang>
`0:" at the following times:\n";`0:r[;14+!19]</lang>

Output:
Output:
Maximum simultaneous license use is 99 at the following times:

2008/10/03_08:39:34
<lang K>Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40</lang>


=={{header|Julia}}==
=={{header|Julia}}==
{{works with|Julia|0.6}}
{{works with|Julia|0.6}}
{{trans|Python}}
{{trans|Python}}

<lang julia>function maximumsimultlicenses(io::IO)
<lang julia>function maximumsimultlicenses(io::IO)
out, maxout, maxtimes = 0, -1, String[]
out, maxout, maxtimes = 0, -1, String[]
Line 1,373: Line 1,317:
println("Maximum simultaneous license use is $maxout at the following times: \n - ", join(maxtimes, "\n - "))
println("Maximum simultaneous license use is $maxout at the following times: \n - ", join(maxtimes, "\n - "))
end</lang>
end</lang>

{{out}}
{{out}}
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
- 2008/10/03_08:39:34
- 2008/10/03_08:39:34
- 2008/10/03_08:40:40</pre>
- 2008/10/03_08:40:40


=={{header|Kotlin}}==
=={{header|Kotlin}}==
Line 1,411: Line 1,354:
println(dates.map { " $it" }.joinToString("\n"))
println(dates.map { " $it" }.joinToString("\n"))
}</lang>
}</lang>

The file used for testing:
The file used for testing:
<pre>License OUT @ 2008/10/03_23:51:05 for job 4974
<pre>
License OUT @ 2008/10/03_23:51:05 for job 4974
License OUT @ 2008/10/03_23:57:00 for job 4975
License OUT @ 2008/10/03_23:57:00 for job 4975
License IN @ 2008/10/04_00:00:06 for job 4975
License IN @ 2008/10/04_00:00:06 for job 4975
License OUT @ 2008/10/04_00:07:19 for job 4976
License OUT @ 2008/10/04_00:07:19 for job 4976
License IN @ 2008/10/04_00:11:32 for job 4976
License IN @ 2008/10/04_00:11:32 for job 4976
License IN @ 2008/10/04_00:18:22 for job 4974
License IN @ 2008/10/04_00:18:22 for job 4974</pre>
</pre>

{{out}}
{{out}}
Maximum simultaneous license use is 2 at the following time(s):
<pre>
Maximum simultaneous license use is 2 at the following time(s):
2008/10/03_23:57:00
2008/10/03_23:57:00
2008/10/04_00:07:19
2008/10/04_00:07:19
</pre>


=={{header|Lua}}==
=={{header|Lua}}==
Line 1,461: Line 1,398:
end</lang>
end</lang>
Output:
Output:
<pre>Maximum licenses in use: 99
Maximum licenses in use: 99
Occurrences:
Occurrences:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
2008/10/03_08:40:40


=={{header|M4}}==
=={{header|M4}}==
<lang M4>
<lang M4>divert(-1)
divert(-1)
define(`current',0)
define(`current',0)
define(`max',0)
define(`max',0)
Line 1,479: Line 1,415:
divert
divert
max
max
undivert(1)
undivert(1)</lang>
</lang>

Output:
Output:
99
<pre>
99
@ 2008/10/03_08:39:34 @ 2008/10/03_08:40:40
@ 2008/10/03_08:39:34 @ 2008/10/03_08:40:40
</pre>


=={{header|Mathematica}}==
=={{header|Mathematica}}==
Line 1,497: Line 1,429:


Output:
Output:
<pre>-> The maximum number of licenses used was 99, at {2008/10/03_08:39:34,2008/10/03_08:40:40}</pre>
-> The maximum number of licenses used was 99, at {2008/10/03_08:39:34,2008/10/03_08:40:40}


=={{header|MAXScript}}==
=={{header|MAXScript}}==
Line 1,543: Line 1,475:
licencesInUse()</lang>
licencesInUse()</lang>
Output
Output
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
2008/10/03_08:40:40


=={{header|Nim}}==
=={{header|Nim}}==
Line 1,567: Line 1,499:
for i in maxTimes: echo " ",i</lang>
for i in maxTimes: echo " ",i</lang>
Output:
Output:
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
2008/10/03_08:40:40


=={{header|OCaml}}==
=={{header|OCaml}}==
Line 1,603: Line 1,535:
=={{header|Oz}}==
=={{header|Oz}}==
{{trans|Python}}
{{trans|Python}}

<lang oz>declare
<lang oz>declare
fun {MaxLicenses Filename ?Times}
fun {MaxLicenses Filename ?Times}
Line 1,655: Line 1,586:


Output:
Output:
Maximum simultaneous license use is 99 at the following times:
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
Line 1,680: Line 1,609:
rec
rec
};</lang>
};</lang>
<pre>["2008/10/03_08:39:34", "2008/10/03_08:40:40"]
["2008/10/03_08:39:34", "2008/10/03_08:40:40"]
%1 = 99</pre>
%1 = 99


=={{header|Perl}}==
=={{header|Perl}}==
Line 1,712: Line 1,641:
print " $_\n" foreach @max_times;</lang>
print " $_\n" foreach @max_times;</lang>
Example output:
Example output:
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40

</pre>


=={{header|Perl 6}}==
=={{header|Perl 6}}==
Line 1,750: Line 1,679:


Example output:
Example output:
Maximum concurrent licenses in use: 99, in the time periods:
<pre>
2008/10/03_08:39:34 through 2008/10/03_08:39:45,
Maximum concurrent licenses in use: 99, in the time periods:
2008/10/03_08:39:34 through 2008/10/03_08:39:45,
2008/10/03_08:40:40 through 2008/10/03_08:40:47
2008/10/03_08:40:40 through 2008/10/03_08:40:47
</pre>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,793: Line 1,720:
end for</lang>
end for</lang>
{{out}}
{{out}}
Maximum simultaneous license use is 99 at the following times:
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|PHP}}==
=={{header|PHP}}==
Line 1,829: Line 1,754:
echo $times[$i] . '<br>';
echo $times[$i] . '<br>';
}</lang>
}</lang>
99
<pre>
2008/10/03_08:39:34
99
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang pli>text3: procedure options (main); /* 19 November 2011 */
<lang pli>
text3: procedure options (main); /* 19 November 2011 */
declare line character (80) varying;
declare line character (80) varying;
declare (nout, max_nout) fixed;
declare (nout, max_nout) fixed;
Line 1,872: Line 1,794:
free saveline;
free saveline;
end;
end;
end text3;
end text3;</lang>
</lang>
OUTPUT:
OUTPUT:
The maximum number of licences taken out = 99
<pre>
It occurred at 2008/10/03_08:40:40 for job 1837
The maximum number of licences taken out = 99
It occurred at 2008/10/03_08:40:40 for job 1837
It occurred at 2008/10/03_08:39:34 for job 1833
It occurred at 2008/10/03_08:39:34 for job 1833
</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
{{trans|AWK}}
{{trans|AWK}}

Put the following into an executable file "licenses":
Put the following into an executable file "licenses":
<lang PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
<lang PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
Line 1,905: Line 1,823:
(bye)</lang>
(bye)</lang>
Then it can be called as
Then it can be called as
<pre>$ ./licenses mlijobs.txt
$ ./licenses mlijobs.txt
The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !</pre>
The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang PowerShell>
<lang PowerShell>[int]$count = 0
[int]$count = 0
[int]$maxCount = 0
[int]$maxCount = 0
[datetime[]]$times = @()
[datetime[]]$times = @()
Line 1,954: Line 1,871:
StartTime = $times[0]
StartTime = $times[0]
EndTime = $times[1]
EndTime = $times[1]
}</lang>
}
</lang>
{{Out}}
{{Out}}
LicensesOut StartTime EndTime
<pre>
LicensesOut StartTime EndTime
----------- --------- -------
99 10/3/2008 8:39:34 AM 10/3/2008 8:40:40 AM
----------- --------- -------
99 10/3/2008 8:39:34 AM 10/3/2008 8:40:40 AM
</pre>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
Line 1,989: Line 1,903:
PrintN(#CRLF$+"Press ENTER to exit"): Input()
PrintN(#CRLF$+"Press ENTER to exit"): Input()
CloseConsole()</lang>
CloseConsole()</lang>
99 license(s) used at ;
<pre>
2008/10/03_08:39:34
99 license(s) used at ;
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
Press ENTER to exit

Press ENTER to exit
</pre>


=={{header|Python}}==
=={{header|Python}}==
Line 2,008: Line 1,920:
print("Maximum simultaneous license use is %i at the following times:" % max_out)
print("Maximum simultaneous license use is %i at the following times:" % max_out)
print(' ' + '\n '.join(max_times))</lang>
print(' ' + '\n '.join(max_times))</lang>

{{out}}
{{out}}
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|R}}==
=={{header|R}}==
<lang R># Read in data, discard useless bits
<lang R>
# Read in data, discard useless bits
dfr <- read.table("mlijobs.txt")
dfr <- read.table("mlijobs.txt")
dfr <- dfr[,c(2,4)]
dfr <- dfr[,c(2,4)]
Line 2,026: Line 1,935:
when.most.checked.out <- times[which(n.checked.out==most.checked.out)]
when.most.checked.out <- times[which(n.checked.out==most.checked.out)]
# As a bonus, plot license use
# As a bonus, plot license use
plot(times, n.checked.out, type="s")
plot(times, n.checked.out, type="s")</lang>
</lang>


=={{header|Racket}}==
=={{header|Racket}}==
Line 2,055: Line 1,963:
(printf "Maximum licences in simultaneously used is ~a at the following times:~%"
(printf "Maximum licences in simultaneously used is ~a at the following times:~%"
max-used)
max-used)
(for-each displayln max-used-when)
(for-each displayln max-used-when)</lang>
</lang>
Output:
Output:
<pre>Maximum licences in simultaneously used is 99 at the following times:
Maximum licences in simultaneously used is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
2008/10/03_08:40:40

The following takes advantage of a combination of ''for/fold'' and ''(in-lines)'' (and is possible more in the Racket idiom, rather than just using ''(read-line)'' and ''(regexp-match)'':
The following takes advantage of a combination of ''for/fold'' and ''(in-lines)'' (and is possible more in the Racket idiom, rather than just using ''(read-line)'' and ''(regexp-match)'':


Line 2,112: Line 2,018:
end /*j*/ /*stick a fork in it, we're all done. */</lang>
end /*j*/ /*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; when using the default input file:
'''output''' &nbsp; when using the default input file:
<pre>10000 records read from the input file: LICENSE.LOG
<pre>
10000 records read from the input file: LICENSE.LOG
The maximum number of licenses out is 99 at:
The maximum number of licenses out is 99 at:


2008/10/03_08:39:34 for job 1833
2008/10/03_08:39:34 for job 1833
2008/10/03_08:40:40 for job 1837
2008/10/03_08:40:40 for job 1837</pre>
</pre>

===Version 2 dual-coded for PC and TSO===
===Version 2 dual-coded for PC and TSO===
It should be noted that almost every REXX interpreter returns a different string for &nbsp; '''parse source''' &nbsp; under Microsoft Windows:
It should be noted that almost every REXX interpreter returns a different string for &nbsp; '''parse source''' &nbsp; under Microsoft Windows:
Line 2,198: Line 2,101:
Return</lang>
Return</lang>
{{out}} on Windows
{{out}} on Windows
<pre>
<pre>D:\>rexx maxl
D:\>rexx maxl
WindowsNT COMMAND D:\maxl.rex
WindowsNT COMMAND D:\maxl.rex
The maximum number of licences taken out = 99
The maximum number of licences taken out = 99
Line 2,264: Line 2,166:


Example output:
Example output:
<pre>Maximum simultaneous license use is 99 at the following times:
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>
=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang lb>open "c:\data\temp\logFile.txt" for input as #f
<lang lb>open "c:\data\temp\logFile.txt" for input as #f
Line 2,282: Line 2,183:
wend
wend
print maxCount;" ";theDate$</lang>
print maxCount;" ";theDate$</lang>

=={{header|Scala}}==
=== Dumb imperative translations ===
The boolean logic e.g. is rather clumsy.
{{trans|Ada}}
{{trans|ALGOL 68}}
{{trans|AutoHotkey}}
{{trans|AWK}}
{{trans|Common Lisp}}
{{trans|E}}
{{trans|Fortran}}
{{trans|Go}}
{{trans|Python}}
{{trans|Java}}
{{trans|Julia}}
{{trans|MAXScript}}
{{trans|Nim}}
{{trans|OCaml}}
{{trans|Perl}}
{{trans|PL/I}}
{{trans|PureBasic}}
{{trans|R}}
{{trans|REXX}}
{{trans|Ruby}}
{{trans|Run BASIC}}
{{trans|Sidef}}
{{trans|Tcl}}
{{trans|Zcl}}
{{Out}}Best seen running in your browser [https://scastie.scala-lang.org/lTzl4t0cRFORGs9YWtvgAQ Scastie (remote JVM)].
<lang Scala>import java.io.{BufferedReader, InputStreamReader}
import java.net.URL

object License0 extends App {
val url = new URL("https://raw.githubusercontent.com/def-/nim-unsorted/master/mlijobs.txt")
val in = new BufferedReader(new InputStreamReader(url.openStream()))

val dates = new collection.mutable.ListBuffer[String]
var (count: Int, max: Int) = (0, Int.MinValue)
var line: String = _

while ( {line = in.readLine; line} != null) {
if (line.startsWith("License OUT ")) count += 1
if (line.startsWith("License IN ")) count -= 1 // Redundant test when "OUT"
if (count > max) { // Fruitless execution when "License IN "
max = count
val date = line.split(" ")(3)
dates.clear()
dates += date
} else if (count == max) {
val date = line.split(" ")(3)
dates += date
}
}

println("Max licenses out: " + max)
println("At time(s): " + dates)

}</lang>
{{in progress|lang=LANG|day=DD|month=MM|year=YYYY}}
//


=={{header|Seed7}}==
=={{header|Seed7}}==
Line 2,317: Line 2,278:
end for;
end for;
end func;</lang>
end func;</lang>

Output:
Output:
Maximum simultaneous license use is 99 at the following times:
<pre>
2008/10/03_08:39:34
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Sidef}}==
=={{header|Sidef}}==
Line 2,345: Line 2,303:
max_times.each {|t| " #{t}".say };</lang>
max_times.each {|t| " #{t}".say };</lang>
{{out}}
{{out}}
$ sidef max_licenses.sf < mlijobs.txt
<pre>
Maximum simultaneous license use is 99 at the following times:
$ sidef max_licenses.sf < mlijobs.txt
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Tcl}}==
=={{header|Tcl}}==

{{trans|Python}}
{{trans|Python}}

<lang tcl> set out 0
<lang tcl> set out 0
set max_out -1
set max_out -1
Line 2,379: Line 2,333:
puts " $t"
puts " $t"
}</lang>
}</lang>

Output matches Python
Output matches Python
=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
<lang tuscript>
<lang tuscript>$$ MODE TUSCRIPT
$$ MODE TUSCRIPT
joblog="mlijobs.txt",jobnrout=0
joblog="mlijobs.txt",jobnrout=0
log=FILE (joblog)
log=FILE (joblog)
Line 2,400: Line 2,352:
times=SELECT (time,#maxlicout)
times=SELECT (time,#maxlicout)
PRINT "The max. number of licences out is ", maxlicout
PRINT "The max. number of licences out is ", maxlicout
PRINT "at these times: ", times
PRINT "at these times: ", times</lang>
</lang>
Output:
Output:
The max. number of licences out is 99
<pre>
at these times: 2008/10/03_08:39:34 2008/10/03_08:40:40
The max. number of licences out is 99
at these times: 2008/10/03_08:39:34 2008/10/03_08:40:40
</pre>


=={{header|Ursala}}==
=={{header|Ursala}}==
Four functions are defined. Log lexes the log file, which can be accessed as a pre-declared constant without explicit I/O by being given as a compile-time command line parameter. Scan accumulates running totals of licenses in use. Search identifies the maxima, and format transforms the results to human readable form.
Four functions are defined. Log lexes the log file, which can be accessed as a pre-declared constant without explicit I/O by being given as a compile-time command line parameter. Scan accumulates running totals of licenses in use. Search identifies the maxima, and format transforms the results to human readable form.
<lang Ursala>#import std

<lang Ursala>
#import std
#import nat
#import nat


Line 2,424: Line 2,371:
main = format search scan log</lang>
main = format search scan log</lang>
output:
output:
<pre>99 licenses in use at
99 licenses in use at
2008/10/03_08:39:34
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40
</pre>


=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==
Line 2,457: Line 2,403:
Reg_Type(10)
Reg_Type(10)


Buf_Quit(OK)
Buf_Quit(OK)</lang>
</lang>


Output:
Output:
<pre>Maximum simultaneous license use is 99 at the following times:
<pre>
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34 for job 1833
2008/10/03_08:39:34 for job 1833
2008/10/03_08:40:40 for job 1837
2008/10/03_08:40:40 for job 1837</pre>
</pre>


=={{header|zkl}}==
=={{header|zkl}}==
Line 2,480: Line 2,423:
" the following times:\n %s").fmt(maxOut,maxTimes.concat("\n")));</lang>
" the following times:\n %s").fmt(maxOut,maxTimes.concat("\n")));</lang>
{{out}}
{{out}}
<pre>Maximum simultaneous license use is 1 at the following times:
<pre>
2008/10/03_23:51:05</pre>
Maximum simultaneous license use is 1 at the following times:
2008/10/03_23:51:05
</pre>



{{omit from|GUISS}}
{{omit from|GUISS}}