Text processing/Max licenses in use: Difference between revisions

Content added Content deleted
(Scala contribution added.)
m (Reverted edits by Cloudius (talk) to last revision by Gpapo)
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 [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.
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.


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 88: Line 89:
end licenselist;</lang>
end licenselist;</lang>
Output:
Output:
<pre>
The max. number of licenses out is 99
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 172: Line 174:
)</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:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


=={{header|APL}}==
=={{header|APL}}==
Line 184: Line 188:
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>
Maximum simultaneous license use is 99 at the following times:
<lang apl>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</lang>


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


Line 210: Line 215:
}
}


MsgBox Maximum use is %max_out% at:`n`n%max_times%</lang>
MsgBox Maximum use is %max_out% at:`n`n%max_times%
</lang>
Maximum use is 99 at:
<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 234: Line 242:


'''Sample output'''
'''Sample output'''
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 !</pre>


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 270: Line 278:
END</lang>
END</lang>
'''Output:'''
'''Output:'''
<pre>
Maximum licences checked out = 99
Maximum licences checked out = 99
From 2008/10/03_08:39:34 to 2008/10/03_08:40:40
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 292: Line 303:
)
)
| out$(!N !Ts)
| out$(!N !Ts)
);</lang>
);
</lang>
Output:
Output:
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</pre>


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

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


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


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang csharp>using System;
<lang csharp>
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
Line 503: Line 516:
}
}
}
}
}
}</lang>
</lang>
99
<pre>
2008/10/03_08:39:34
99
2008/10/03_08:40:40
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 526: Line 543:
(map println times))</lang>
(map println times))</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:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


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


=={{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 644: Line 665:
(push time max-log-times)))))))</lang>
(push time max-log-times)))))))</lang>


> (max-licenses)
<pre>> (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
NIL</pre>

=={{header|D}}==
=={{header|D}}==
<lang d>void main() {
<lang d>void main() {
Line 669: Line 691:
}</lang>
}</lang>
{{out}}
{{out}}
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"
"2008/10/03_08:39:34"
"2008/10/03_08:40:40"
"2008/10/03_08:40:40"</pre>


=={{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 699: Line 723:
}</lang>
}</lang>
=={{header|Eiffel}}==
=={{header|Eiffel}}==
<lang Eiffel>class
<lang Eiffel>
class
APPLICATION
APPLICATION


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


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


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


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


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


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

Output:
Output:
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
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 911: Line 946:


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth>20 constant date-size
<lang forth>
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 943: Line 979:
max-dates count type cr ;
max-dates count type cr ;


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


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


<lang fortran> PROGRAM MAX_LICENSES
<lang fortran>
PROGRAM MAX_LICENSES
IMPLICIT NONE
IMPLICIT NONE
Line 984: Line 1,022:
WRITE(*,"(A)") maxtime(1:maxcount)
WRITE(*,"(A)") maxtime(1:maxcount)
END PROGRAM MAX_LICENSES</lang>
END PROGRAM MAX_LICENSES
</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>@set{count;0};@set{max;0}
<lang gema>
@set{count;0};@set{max;0}


License OUT \@ * *\n=@incr{count}@testmax{${count},*}
License OUT \@ * *\n=@incr{count}@testmax{${count},*}
Line 1,000: Line 1,041:
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*</lang>
report:*,*=Maximum simultaneous license use is * at\n*
</lang>
Output:
Output:
<pre>
Maximum simultaneous license use is 99 at
Maximum simultaneous license use is 99 at
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|Go}}==
=={{header|Go}}==
Line 1,068: Line 1,112:
}</lang>
}</lang>
{{out}}
{{out}}
<pre>
max licenses: 99
max licenses: 99
at:
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,102: Line 1,148:


println "Maximum Licenses $max"
println "Maximum Licenses $max"
dates.each { date -> println " $date" }</lang>
dates.each { date -> println " $date" }
</lang>
Output:
Output:
<pre>
Maximum Licenses 99
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>import Data.List
<lang haskell>
import Data.List


main = do
main = do
Line 1,117: Line 1,167:
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</lang>
mapM_ (putStrLn . (dt!!)) . elemIndices mo $ cio
</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,171: Line 1,221:


And a run of the program:
And a run of the program:
->ml <mlijobs.txt
<pre>->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,185: Line 1,236:
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,221: Line 1,274:
}
}
}</lang>
}</lang>
Max licenses out: 99
<pre>Max licenses out: 99
At time(s): [2008/10/03_08:39:34, 2008/10/03_08:40:40]
At time(s): [2008/10/03_08:39:34, 2008/10/03_08:40:40]</pre>


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


output:
output:
Max licenses out: 99
<pre>Max licenses out: 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|jq}}==
=={{header|jq}}==
{{works with|jq|1.4}}
{{works with|jq|1.4}}
Line 1,291: Line 1,344:
`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:
<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:39:34
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,317: Line 1,373:
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}}
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
- 2008/10/03_08:39:34
- 2008/10/03_08:40:40
- 2008/10/03_08:40:40</pre>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
Line 1,354: Line 1,411:
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>
<pre>License OUT @ 2008/10/03_23:51:05 for job 4974
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</pre>
License IN @ 2008/10/04_00:18:22 for job 4974
</pre>

{{out}}
{{out}}
<pre>
Maximum simultaneous license use is 2 at the following time(s):
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,398: Line 1,461:
end</lang>
end</lang>
Output:
Output:
Maximum licenses in use: 99
<pre>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
2008/10/03_08:40:40</pre>


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

Output:
Output:
<pre>
99
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,429: Line 1,497:


Output:
Output:
-> 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}</pre>


=={{header|MAXScript}}==
=={{header|MAXScript}}==
Line 1,475: Line 1,543:
licencesInUse()</lang>
licencesInUse()</lang>
Output
Output
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
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40</pre>


=={{header|Nim}}==
=={{header|Nim}}==
Line 1,499: Line 1,567:
for i in maxTimes: echo " ",i</lang>
for i in maxTimes: echo " ",i</lang>
Output:
Output:
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
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:40:40</pre>


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

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


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:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


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


=={{header|Perl}}==
=={{header|Perl}}==
Line 1,641: Line 1,712:
print " $_\n" foreach @max_times;</lang>
print " $_\n" foreach @max_times;</lang>
Example output:
Example output:
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
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,679: Line 1,750:


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


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,720: Line 1,793:
end for</lang>
end for</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:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


=={{header|PHP}}==
=={{header|PHP}}==
Line 1,754: Line 1,829:
echo $times[$i] . '<br>';
echo $times[$i] . '<br>';
}</lang>
}</lang>
<pre>
99
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|PL/I}}==
=={{header|PL/I}}==
<lang pli>
<lang pli>text3: procedure options (main); /* 19 November 2011 */
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,794: Line 1,872:
free saveline;
free saveline;
end;
end;
end text3;</lang>
end text3;
</lang>
OUTPUT:
OUTPUT:
<pre>
The maximum number of licences taken out = 99
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:40:40 for job 1837
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,823: Line 1,905:
(bye)</lang>
(bye)</lang>
Then it can be called as
Then it can be called as
$ ./licenses mlijobs.txt
<pre>$ ./licenses mlijobs.txt
The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !
The biggest number of licenses is 99 at 2008/10/03_08:39:34 and 2008/10/03_08:40:40 !</pre>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang PowerShell>[int]$count = 0
<lang PowerShell>
[int]$count = 0
[int]$maxCount = 0
[int]$maxCount = 0
[datetime[]]$times = @()
[datetime[]]$times = @()
Line 1,871: Line 1,954:
StartTime = $times[0]
StartTime = $times[0]
EndTime = $times[1]
EndTime = $times[1]
}
}</lang>
</lang>
{{Out}}
{{Out}}
<pre>
LicensesOut StartTime EndTime
----------- --------- -------
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,903: Line 1,989:
PrintN(#CRLF$+"Press ENTER to exit"): Input()
PrintN(#CRLF$+"Press ENTER to exit"): Input()
CloseConsole()</lang>
CloseConsole()</lang>
<pre>
99 license(s) used at ;
99 license(s) used at ;
2008/10/03_08:39:34
2008/10/03_08:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40

Press ENTER to exit
Press ENTER to exit
</pre>


=={{header|Python}}==
=={{header|Python}}==
Line 1,920: Line 2,008:
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}}
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
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>
<lang R># Read in data, discard useless bits
# 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 1,935: Line 2,026:
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")</lang>
plot(times, n.checked.out, type="s")
</lang>


=={{header|Racket}}==
=={{header|Racket}}==
Line 1,963: Line 2,055:
(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)</lang>
(for-each displayln max-used-when)
</lang>
Output:
Output:
Maximum licences in simultaneously used is 99 at the following times:
<pre>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
2008/10/03_08:40:40</pre>

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,018: Line 2,112:
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>
<pre>10000 records read from the input file: LICENSE.LOG
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</pre>
2008/10/03_08:40:40 for job 1837
</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,101: Line 2,198:
Return</lang>
Return</lang>
{{out}} on Windows
{{out}} on Windows
<pre>D:\>rexx maxl
<pre>
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,166: Line 2,264:


Example output:
Example output:
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
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,183: Line 2,282:
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,278: Line 2,317:
end for;
end for;
end func;</lang>
end func;</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:40:40
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>


=={{header|Sidef}}==
=={{header|Sidef}}==
Line 2,303: Line 2,345:
max_times.each {|t| " #{t}".say };</lang>
max_times.each {|t| " #{t}".say };</lang>
{{out}}
{{out}}
<pre>
$ sidef max_licenses.sf < mlijobs.txt
$ sidef max_licenses.sf < mlijobs.txt
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|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,333: Line 2,379:
puts " $t"
puts " $t"
}</lang>
}</lang>

Output matches Python
Output matches Python
=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
<lang tuscript>$$ MODE TUSCRIPT
<lang tuscript>
$$ MODE TUSCRIPT
joblog="mlijobs.txt",jobnrout=0
joblog="mlijobs.txt",jobnrout=0
log=FILE (joblog)
log=FILE (joblog)
Line 2,352: Line 2,400:
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</lang>
PRINT "at these times: ", times
</lang>
Output:
Output:
<pre>
The max. number of licences out is 99
The max. number of licences out is 99
at these times: 2008/10/03_08:39:34 2008/10/03_08:40:40
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,371: Line 2,424:
main = format search scan log</lang>
main = format search scan log</lang>
output:
output:
99 licenses in use at
<pre>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,403: Line 2,457:
Reg_Type(10)
Reg_Type(10)


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


Output:
Output:
<pre>
<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 for job 1833
2008/10/03_08:39:34 for job 1833
2008/10/03_08:40:40 for job 1837</pre>
2008/10/03_08:40:40 for job 1837
</pre>


=={{header|zkl}}==
=={{header|zkl}}==
Line 2,423: Line 2,480:
" 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>
<pre>Maximum simultaneous license use is 1 at the following times:
Maximum simultaneous license use is 1 at the following times:
2008/10/03_23:51:05</pre>
2008/10/03_23:51:05
</pre>



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