We had the second Ruby Golf competition this year. Our goal was to compute a score for each hole and provide a web site to check live rankings. See axelerator/ruby_caddy for the Rails app used to compute the scores and display the ranking.
An honorable mention of the most effective solution in the category "Gaming The System" goes to team Peter Schröder who put their code inside the method signature and thus managed to get down to 1 character per method most of the time. Great idea, but too far off for being counted as a real implementation. Also because it mainly was an input/output mapping, no algorithmic implementation. So we had to disqualify this entry.
- Tammo & Timo (Also "Gaming The System" since all code was converted to whitespace which could be evaluated on runtime. Since all whitespace is eliminated for counting, the solutions all have the same length which is the code for evaluating the whitespace. Cheaty, but still this implemented the tasks we asked for.)
- Team Schröder 2 (An alter ego of team Peter Schröder providing their solution before they became too creative.)
- Jan
- Marc
- anton
- Daniel
- Thomas von Deyen
- Ben
- Tim
If you check ruby_golf.rb, you'll find a compilation of the shortest non cheating solutions from all golfers:
- Hole 1: 33 characters from Daniel
- Hole 2: 43 characters from Jan
- Hole 3: 62 characters from Daniel
- Hole 4: 98 characters from Jan
- Hole 5: 24 characters from Jan and Thomas von Deyen
- Hole 6: 117 characters from Jan
- Hole 7: 110 characters from Jan
- Hold 8: 138 characters from Jan
Let me say that without any cheating, Jan probably would have won.
- Don't exclude whitespace completely, maybe just the initial indentation.
- Don't ignore method signature in counting characters.
- Test with more examples to avoid quickfix solutions not implementing the proper algorithm and prevent simple input/output mappings instead of real code.
- Check code during competition and give hints what to avoid.
- Try to even out team sizes since bigger teams definitely have an advantage.
To start coding on this challenge, first install all gems:
bundle install
Then, execute the test using guard:
bundle exec guard
Each time you change ruby_golf.rb, the tests are re-run and give you the state of your implementation and code metrics used for ranking.
- only touch
ruby_golf.rb
- implement your solution within the pre-defined module methods
- only non-whitespace characters within the method body are counted, no need to optimize the method definition
- you can implement helper methods within the module, but be aware that they are counted towards the size of each method they're used in
- stick to what stdlib gives you
- DON'T use custom gems
- DON'T go and annoy the organizers by being clever and exploiting their code