Talk:Text processing/Max licenses in use

From Rosetta Code

Assumptions

We might be better able to compare code if we document our assumptions.

Not quite sure what you mean here? Assume that you have the 10000 line file as given. You could check on char 8 by scanning the file beforehand, but I could just say that it is like the example in the header where apart from the width of the last field in a line, then other fields are fixed width, and in fixed order. But again, you could write code to verify this too. The last line of the file may or may not end in a newline depending on how it was grabbed from the URL. (I take it that you were successful DanBron, thanks. It's the first time I've used google docs to distribute data in this way - If Rosetta Code could possibly upload a zipped version??? )
As for assuming the file exists, I would expect examples to not check whether the file exists or if it was zero length. for the purpose of the exercise, just run on the data and report a result. If you have a different algorithm to those present then you might want to start a discussion in this talk section, for example - given the size of the input, someone might slurp in the whole file in one go rather than accumulating data line-by-line. --Paddy3118 04:24, 4 October 2008 (UTC)

J

The J solution makes assumptions to allow the interesting code to stand out (rather than the drudgery). This obviously comes at the cost of some robustness (and, incidentally, optimizes for speed).

  • Assumes the file ends in a newline.
  • Assumes the format of the file is fixed (that char 8 of each line is 'I' or 'O' as the license is checked in or out, respectively, and that the date is chars 14-32 of each line).
  • Does not assume the file exists or, if it exists, that it contains any data (i.e. it may be zero bytes long). For example, if the file is empty, you get this:
Maximum simultaneous license use is 0 at the following times:
Note that I didn't have to do any special checks to get this behavior, it just fell naturally out of the code. (This happens a lot in J.)

File hosting

Not that I have anything against Google Documents, but would I'd like to put the file on RC's server. --Short Circuit 04:11, 4 October 2008 (UTC)

Please, please please, please please please please. Thanks :-)
Could you also update the problem statement to show how to get the relocated file, thanks. --Paddy3118 04:27, 4 October 2008 (UTC)
Is there a story to this document? Where did it come from? What's its copyright? --Short Circuit 06:02, 4 October 2008 (UTC)
The file is of directed random data generated by me and to a file format that I created. Please feel free to re-host under your normal RC terms. --Paddy3118 09:40, 4 October 2008 (UTC)