Ah, just like real projects
What do you mean you weren't told you should have started on the 28th of June?
Is it also possible to request a language that is less noddy than Java, VB, Swift, C'Dent, Node, PHP, or Python?
Competition closed.
SQL ... yes you can do it. However it would be pretty slow and you would need a SQL engine ... (Isn't that outside of the rules ? )
However, it would be trivial to do in Scala.
Which means its trivial in Java or C too.
Seriously... is this a contest to stretch your skills or for college kids?
I can supply more codes if needed.
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <base href="http://www.theregister.co.uk/"> <title>The Reg Coding competition – 10 times as hard as the last one! • The Register Forums</title>
<link rel=alternate type="application/atom+xml" href="http://forums.theregister.co.uk/feed/forum/2016/07/13/the_reg_coding_competition_10_times_as_hard_as_the_last_one/" title="Posts in this topic">
<link rel=stylesheet href="http://www.theregister.co.uk/style_picker/forums?a"> <script>
var RegArticle={id:179309,pf:0,af:0,bms:0,cat:'news',ec:[],kw:[['competition','Competition'],['coding','Coding']],short_url:'http://reg.cx/2mN3',cp:1,noads:[],ads:['ibmcds16-11753'],author:'David Gordon',vid:0}
</script>
<style type="text/css">#forums-nav-link { font-weight: bold }</style>
<link rel=stylesheet type="text/css" href="/style_picker/design?ca">
<style>
#sec-none a,
#sub-sec-none a {
font-weight: bold;
}
</style>
<link rel=alternate type="application/atom+xml" href="/headlines.atom" title="The Register: whole site">
<script src="/Design/javascript/_.js?ca"></script>
<script>var RegEditWindowMins = 10;</script> </head>
The IT director here who knows how to code in C (badly and has no formal dev training , hes a stats guy) actually used a bubble sort in the original code for this place. it took around 5 mins to sort 50K keys! I swapped it out for a shell sort (couldn't use standard qsort() function for reasons I wont bore you with and didnt have time to roll my own) which brought the sort time down to 0.3 secs.
Other wonders of his original code included 3000 lines functions, the entire program in one 20K file, next to no comments, fixed sized char[] arrays (with some nice overflow bugs) using "if (0)" instead of #ifdefs and single letter variable and array names everywhere.
Never let non coders near an editor or compiler!
[i]Never let non coders near an editor or compiler![/i]
I have to admit, back in the days when a 286 with 4MB was the best one had, I had to convert a huge stock database with new part codes and a new format, each entry a line of text. Had it all done bar sorting it and that was proving a challenge at the time. Up popped a sales droid, who imported it into Excel which had it sorted and done before I even blinked.
> I would fail anything that took more that 1second.... is this the state of programming in 2016 !
Since there is no mention of an upper limit on the number of datasets, I'm sure I could produce an input file that would cause your entry to either crash or take longer than 1 sec. ;-)
"is this the state of programming in 2016 !"
The state of programming in 2016 is that you should allocate at least 58.5 seconds to initialize the JVM, load the python interpreter, load the GUI framework libraries, establish a connection to the local MySQL server (and start the server if this is the first execution), then display a splash screen, load libraries from 8 different remote repositories, and display the first banner ad.
Hello, world.
Two months to rip out *one* Python program with stdio and some "trixy" formatting rules?
How much work is this going to be, really? Is there only one question - "The Question"?. Or is it one per week, day, hour, phase o' the moon? The "Time Limit" paragraph hints at "Questions"?!
How much work is this going to be, really? Is there only one question - "The Question"?. Or is it one per week, day, hour, phase o' the moon? The "Time Limit" paragraph hints at "Questions"?!"
Exactly my first thought.
Then I realised that the actual challenge was in fact more life-like: make sense of an ambiguous specification ... !
And what the hell is C'Dent??
It's a distraction for those with too much time on their hands.
"It's a distraction for those with too much time on their hands."
Looks like another "seemed like a good idea at the time" which will soon disappear when the students writing it get bored and move on to something else. I honestly can't imagine man people bothering to spend the time learning it given if they're into cross platform programming they probably already know Java or Python and will simply use them directly. And if they're webdevs they won't even understand the concept of cross compilers.
looked to me like about 10mins work
That's presumably why they don't let you see the data beforehand. I would imagine there are cases where T>B (for example) and where the precision of T is such that careless floating-point arithmetic will result in the wrong value when rounded down. I'm sure there's more beneath the surface - including the fact that there is no information about the size of the dataset, which could be enormous.
"It looks like they want script kiddies to have a chance at winning and not just have the competition open to proper programmers."
I think its safe to assume each dataset can fit in and be sorted in memory. If part of the problem is to do external sorting in files then thats exponentially harder! However there's nothing that suggests that.
"Having read through the problem then looked to me like about 10mins work with sed/awk/sort/etc"
Getting sort to sort each dataset individually just via a pipe from awk or sed could be ... interesting. I suppose you could process each dataset in awk then use system() to shell out to sort but that starts to get messy pretty quickly.
Self taught, not sure what proper design is. My fail I guess.
Note: none of my code has been exploited yet but I suspect that is due to the obscurity of the sites on which it is being run rather than my coding skill.
Procedural PHP 49 lines.
OO PHP 110 lines.
I notice the sample data file has been corrected.
Should I enter? Perhaps I should search "PHP proper design considerations" before I submit my Stack Exchange copy/paste solution.
- Is the data file supplied on the command line or will it be present in the same folder as the script?
- What is the file encoding of the input and output file? ASCII? ANSI? UTF-x? EBCDIC?
- What end of line marker can be expcted? \n \r\n ?
- Reagan & REAGAN are the same person? Can we expect a unique key of 1 name per event?
The art of programming is modelling a problem in a computer in a useful way.
The problem is almost always ambiguous and much of the skill comes in your ability to cope with the ambiguity and use your best interpretation to deal with it. Presumably this is part of the test.
From your set of questions, it's only output EOL that I cannot deduce with total accuracy...
> Is the data file supplied on the command line or will it be present in the same folder as the script?
"[...] read its input from a file called Decathlon.dat and send its input to a file called Decathlon.out."
That looks like "files in the same directory" with the given hardcoded names.
Additionally: "Your program must produce no screen output."
> What is the file encoding of the input and output file? ASCII? ANSI? UTF-x? EBCDIC?
I'd go with ASCII encoding ("letters", "hyphenated"), but UTF-8 would probably work with my code too, as I wouldn't care about what non-space bytes they separate by spaces and tabs. And then the numbers are all in the 7-bit part of ASCII. Who uses ANSI and EBCDIC with Node, Java or Python anyway? That means they're not even options.
> What end of line marker can be expcted? \n \r\n ?
For input I'd just assume \n and treat \r as "whitespace", because the specs allow for trailing whitespace. For output... that's a tricky one, given that "extraneous output will cause an automatic failure".
I'd go with \n for output only because except VB all the others can run on non-Windows platforms (Linux, BSD, Mac) and produce \n EOLs in those environments. They're promoting cloudiness, and they mainly run Linux in there... I also just realised that Swift is Mac-only, so... \n it is then.
> Reagan & REAGAN are the same person? Can we expect a unique key of 1 name per event?
"Names and event abbreviations must be treated as case-insensitive"
"You may assume that there will be no more than one entry in each data set for a given event for a given competitor, and that there will not be more than one competitor with the same name."
That being said... the terms and conditions say "[...] the fastest and most accurate code"... so you if submit something in Python you're guaranteed to not win anything since Java and Swift will just smoke you. Node is fast, but still way behind Java and Swift.
Nothing to do with Arthur Dent as far as I can see, unfortunately.
From the Website:
"C'Dent is a new Acmeist programming language for writing portable modules. It is based on the computer programming principle known as H.O.P.E. (Hack Once, Please Everyone)"
Hmmmm. Hack Once sounds quite a bit like lashing together.
But this competition looks like bait for Shoreditch wannabe developers (or "hackers" as they seem to want to be known).
Where are C or even C#? What kind of coding competition goes to the effort of having a choice of languages, but leaves out the biggest ones?
Also, frankly, the question is trivial. But I guess it's good to get the kids interested in software.
Actually what I've seen with many people who claim to be good at C++ is that they usually are extremely closed minded and try to stuff everything into what they know.
Also all programming environments have their strengths and weaknesses. For example PHP is good for teaching about SQL-Injections. C++ is good for writing books about and giving lessons.
In practice you must choose the tools that make sense for the problem you are trying to attack. Limiting yourself to some currently "fashionable" language, like this contest does, is a bad idea.
Use a routine to stuff your source code text with backspaces, ^h (ASCII 08 IIRC).
Done correctly in conjunction with same line comments, your apparent source code can appear to do one thing, while actually doing something else when executed.
The scope for mischief is essentially unlimited. One can literally do anything.
More details, copied from an older post.
Within many environments, the user display will dutifully obey the backspace character (ASCII 8), even embedded within the script or code. So by packing in some ASCII backspaces (using a routine to replace a placeholder character with ASCII 8), actual code can be hidden 'beneath' the backspaces, and decorative fake code can be displayed (after a hidden REM).
A BASIC example (from ~33 years ago):
10 PRINT "Yes!"; REM ^h^h^h^h^h^h^h^h^h^h^h "No!"
LIST
10 PRINT "No!"
RUN
Yes!
By this means, what is apparently listed and what is actual hidden code can be perfectly independent. The only clue might be the file size, if they're paying attention and counting characters.
Any environment that obeys the backspace is vulnerable to this mischief.
I mean after all those are all "fancy" OOP languages where people spend 90% of their time learning the new feature that doesn't quite solve the problem they think they have.
The obvious solution on any modern unixoid system is to write a little program, lets say in awk to calculate the scores and write them to a temporary file. If you encounter a #, you close that file, run "sort" over it and format the output. Then you reopen that temporary file and on you go.
Since processing one "dataset" surely takes _much_ less than 5 seconds, it's unlikely your resulting file will ever touch the disk.
If the number of lines per "dataset" is small and bounded, you can also store them in RAM, for example in a statically allocated array of structs, with a smaller array containing the order in which it'll be after sorting.
We live in a world where such problems can be attacked with extremely simple means. For example such a sporting competition might have 2000 contestants with 24 contests. That's 48000 results. Having a 2 dimensional array containing the points is trivial. Even with 128 bit numbers, we are still well below a megabyte. There is no need for a database, you can just write a file and replace it every time a new result comes in.