How to resolve the algorithm Text processing/Max licenses in use step by step in the XPL0 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Text processing/Max licenses in use step by step in the XPL0 programming language
Table of Contents
Problem Statement
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. An example of checkout and checkin events are:
Save the 10,000 line log file from here 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 here (offsite mirror).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Text processing/Max licenses in use step by step in the XPL0 programming language
Source code in the xpl0 programming language
string 0; \use zero-terminated strings
char TimeMax(100, 25);
int Out, OutMax, I, Ch, ListInx;
[Out:= 0; OutMax:= 0; ListInx:= 0;
loop [for I:= 0 to 9-1 do
[Ch:= ChIn(1);
if Ch = $1A \EOF\ then quit;
];
if Ch = ^O then
[Out:= Out+1;
if Out >= OutMax then
[if Out > OutMax then ListInx:= 0;
OutMax:= Out;
for I:= 0 to 5-1 do Ch:= ChIn(1);
for I:= 0 to 19-1 do
TimeMax(ListInx, I):= ChIn(1);
TimeMax(ListInx, I):= 0;
ListInx:= ListInx+1;
];
]
else \Ch = ^I as in "IN"
Out:= Out-1;
repeat Ch:= ChIn(1) until Ch = $0A; \LF
];
Text(0, "Maximum simultaneous license use is ");
IntOut(0, OutMax);
Text(0, " at the following time(s):^m^j");
for I:= 0 to ListInx-1 do
[Text(0, @TimeMax(I,0)); CrLf(0)];
]
You may also check:How to resolve the algorithm Empty program step by step in the MUMPS programming language
You may also check:How to resolve the algorithm Solve a Hidato puzzle step by step in the Bracmat programming language
You may also check:How to resolve the algorithm String comparison step by step in the Raku programming language
You may also check:How to resolve the algorithm Factorial step by step in the Lisaac programming language
You may also check:How to resolve the algorithm N-queens problem step by step in the Fortran programming language