"in favour of lashing together something that just about works after a few user complaints and iteration"
Well that rules me out then
@Daggerchild: Send it in anyway. Just put your name down as Steven Bradbury and hope history repeats itself.
The rules say each program must be submitted as a single zipped text file. This is a bit unnatural for Java, which requires a 1-1 relationship between public classes and source files, although probably feasible in this case. The problem does not appear to require a complex program. Just use a single public class.
My particular favourite for object submission to forums is tar.gz.uu. Winzip actually understands them if you paste the below into a text file, rename it as such, and double click on it. Who needs dropbox?
BEGIN 644 foo.tar.gz
Mblahblahblah..==
END
Now you can have a new way of socially engineering people to give themselves viruses.
This does seem to be a rather poorly-specified compo, ironically enough. What are the judging criteria? The Reg article suggests correct entries will be judged on code quality more than performance, but the compo rules don't say anything one way or the other. It's not at all obvious that a high-quality Java solution can or should be contained in a single source file, but that's what the rules require. There's no indication of typical input data volume, which is necessary in balancing performance against code clarity and simplicity.
How strange.
"For example, a 100m time of 10.2 seconds would be calculated as 25.4347 x (18-10.2)1.81, which works out to 1047.412736, "
Except that 25.4747*(18-10.2)*1.81 = 359.0870946...
So, what mathematical operation does "(18-10.2)1.81" represent if not multiplication?
I suspect it should be exponentiation: 25.4747*pow((18-10.2),1.81)
gives ~1049.
Incidentally, what calculator are you using? I copy and pasted 25.4747*(18-10.2)*1.81
into a console and got 359.6518146
(At any rate, it should be an exact result with no more than 7 decimals since it's multiplication of rationals.)
7 decimals? Are you timing the race to the nearest 10 microseconds?
A time of 10.2 looks to be 3 significant digits to me. If it was more accurate then either the accuracy should be stated or the time written as 10.20.
Applying a little common sense, most sporting events are timed to the 100th of a second, maybe to the millisecond at top events. So for an event when the time is going to be under 18 seconds 4 digits would seem to be the most precision you could realistically claim, 5 at a stretch.
1) Decathlon.dat will be in the working directory of the code.
2) error checking for the existence of the dat fail sorry file will not be required. As it will be there in the right place, guaranteed. And the entrant will not be penalised for such lax coding practice as NOT checking a files existence and the ability to read it before parsing it.
3) error checking for typos in the .dat file will not be required. As BrowserUk pointed out, the format of the dat file does not match the specification.
Coding for perfect input data is easy. Handling every possible error scenario might take a few more lines of code....
The rules ask for the source as a zipped text file, but there are two common text file representations: CRLF terminated lines, like on Windows, and LF terminated lines, like on Linux and other Unix-style systems (I am not sure if any Macs still use CR-terminated lines, I believe the older ones did). Can the judges handle all of these, or must the entry be normalized to one specific format?
45 lines of php, probably less for a skilled php coder.
No error checking other than the working directory can be written to.
No checking that the data file does not contain anything nasty and presuming it is formatted as per the specification.
That was fun, doing things with PHP I don't normally do.
Anyone with half an ounce of sense would recommend either a database solution, or even a simple command line script; the Unix utilities to do this simple kind of data manipulation have been around for longer than half those languages were even an idea.
Looks like more of an undergraduate assignment for the week than a challenge for professionals - perhaps this is a reflection of the malaise affecting IBM these days?
I once saw someone asked to spec a web quiz that gave a result page after a number of multiple choice questions. The schema of the required database was discussed.
At which point they were stopped because you could do the whole thing in flat HTML, just by using a page for each possible combination. To just reach for the big shinies is a trained reflex these days.