MATLAB Programming Contest Blog
May 3rd, 2010
The K-Node Challenge
The Tuesday Longevity Prize has been announced, but for this afternoon, we’ll add another quick contest. The current leader of the contest has grown to almost 500 lines of code and some 16,000 characters of text. From MATLAB’s point of view, that equates to a parse tree with around 3500 nodes. We challenge you, for the next few hours, to figure out how to slim down the current leader in such a way that it still does a good job with only 1000 nodes.
The K-Node Prize will go to the entry with the best score that
- has less than 1000 nodes, and
- is submitted before 22:00 UTC Monday night
As a reminder, this is how you can calculate your node count for any MATLAB file filename.
t = mtree(filename,'-file');
length(t.nodesize)
Please note: you don’t need to shorten your variable names or remove comments to win this challenge. We use node count (and not character or line count) precisely so you can keep the code readable despite being rewarded for brevity.
UPDATE: We’ve added a section to the top of the Statistics page to indicate who’s doing the best on the K-Node challenge. That saves you the trouble of bouncing back and forth between pages to see who has a low node count.
By
Ned Gulley
Ned is part of the MATLAB Central team.
18:42 UTC |
Posted in Sensor |
Permalink |
11 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
Ned: It’d be nice if there was a way to sort entries by node size or to see a current list of who’s leading this contest like we used to be able.
Hi Alan:
Good point. See my update to the post above.
Ned:
That’s great, however the stats section doesn’t seem to be updating with the rest of the page.
Not sure if it is just an updating issue, but it seems there are some new entries that should be topping the K-Node list. For example, my entry “Cycling Nichts” should be better than the current best entry, unless there is something I am not understanding. It has 628 nodes and a better score.
Any advice on how a novice observer can engage with the contest?
@Alan, @cyclist:
You’re right. We were having some difficulties with the UTC time conversion. For the latest, see
http://blogs.mathworks.com/statistics/statistics.html
In a few minutes this will be mirrored to the main stats page.
Can you provide more detail on this concept of node count? A search of your web site doesn’t provide much useful information. Just a repeat of the same sparse text about how to calculate it.
I don’t think it is proper for you to use the undocumented function of mtree to calculate it. I’ve browsed the code for mtree & I can’t figure out if mtree is intended to map out a directory or if it is measuring some feature of a single .m file.
If so, what is a node in the context of a MatLab function?
OysterEngineer, you can think of node count as a rough measure of the number of words and symbols in your program. We picked this metric because it is a measure of the length of the program that doesn’t penalize you for long, descriptive variable names and other goodness.
@OysterEngineer – I have been a long time observer too, but not a competitor… mainly because I work at the MathWorks, but we do have an internal contest before the external one and here is what I used to do:
I download the contest starter kit, and play with the default entry to get an understanding of what it does and what the problem is. If it is still early in the contest (Darkness or Twilight), I would submit a quickly cobbled together entry just to see if it passes. Later in the contest, it is enjoyable to pick up an entry and try to read through it, run it, and try to understand what the different parts of the algorithm are. I’m a bit lazy, so I’m likely to hunt around for entries that are shorter or well commented. If I have any ideas as I go through it, I would try making changes to the entry and if it still runs, resubmit it.
I haven’t played in an internal contest in a couple years, but those are my suggestions for how to get engaged.
It is also pretty interesting to look through the statistics page. For example, if you look down the list of leaders at the %imp (improvement) column, you might see some of the submissions that made big jumps over the previous leader. I find it really interesting to see what kind of change was made to produce the improvement.
Looks like there is another small error on the Statistics page. The latest entry in the “All the Leaders” display seems to have negative time on top.
The statistics page in general is having issues. Most of the graphics at the bottom aren’t updating either.