Hi everybody, anyone willing to share some info about his code (if not his code at all). I am doing this in Ruby in 76B and I use: - 20 to get input - 13 to convert strings to numbers - 11 to output the result - remaining 32B is for algorhythm I wonder if any Rubyst around there could suggest ways to improve in any of these categories. Cheers, Francesco
Dividing code into separate sections is a bit difficult with Perl. The input, output, and processing sections all overlap to create the final solution.
I'm not very proficient in Ruby, but you shouldn't need to convert strings to numbers. Applying mathematical functions to number-like strings should be enough to do the conversion for you.
Apparently someone in Python has gotten it down to 39, and I am completely stumped to how they could possibly do it. I'm only 2 off the previous optimal of 51.
Unfortunately my PHP isn't the best, but I did manage to get less code for input parsing that bnovc: Language: PHP Input: 27 Processing: 62 (ugly) Output: 14
I'd love to see the algorithm you guys came up with for the choose function in PHP. Mirroring the recursive definition given in wikipedia, I got it down to 61 characters, but that's far too large.
Input: 18 Processing: 61 Output: 20 (includes some code that could be considered input parsing)
Total: 91 characters of shame. There are some serious shortcuts for input, in particular, that I obviously don't know yet. The algorithm I'm using is naive and can be improved, but I don't know how to have a more compact input/to int routine... 41 characters to read STDIN is a joke, considering other ruby attempts have the entire answer done in that many characters.
anyone willing to share some info about his code (if not his code at all).
I am doing this in Ruby in 76B and I use:
- 20 to get input
- 13 to convert strings to numbers
- 11 to output the result
- remaining 32B is for algorhythm
I wonder if any Rubyst around there could suggest ways to improve in any of these categories.
Cheers,
Francesco