HNHacker News
TopNewBestAskShowJobs

macobo

187 karma · joined April 21, 2013

submissionscomments
macobo··on JavaScript tool that validates your HTML and warns you in the web console
Link to a CDN in your README, so your users can test the tool more easily.
macobo··on Show HN: Quick and anonymous salary "surveys" at lunch
Are you familiar with the Millionaires' problem? [1]

There's an easy solution when you're looking for an average salary (and everyone doesn't mind doing a little bit of calculation). The first person thinks of a random number, adds his salary to it and tells it to the person on his/her right (so noone else hears!). The next one adds his salary and tells it to the next person and so on. When it re-reaches the first person, he then subtracts the original random number. The result is the sum of their salaries, which can then be divided to yield an average. All done in a way that no one person learns what the salary of any other person was.

[1]: http://en.wikipedia.org/wiki/Yaos_Millionaires_Problem (link sadly broken by HN url parsing?)

macobo··on Ruby is too slow for programming competitions
That's because most contests (but not all) are limited to C, C++ and Java and they've practiced hundreds if not thousands of hours on solving those kinds of problems. Of course they will be more efficient in c++ than a person who is spending most of their time wondering how costly string operations are.

That doesn't mean that there aren't also people who have done the same and still prefer python (or some other language) not for execution, but development speed (and bignum, larger standard library...)

macobo··on Ruby is too slow for programming competitions
This problem has a quite elegant solution - Suppose you know the fair palindromes (is a palindrome and a root of a palindrome) of length 2*k. Then you can add either a single digit or double that to the center, and test if it's fair. This algorithm generates all the fair palindromes. https://gist.github.com/macobo/5430510

By memory, there were under 50000 such palindromes in range 0..10^100.

macobo··on Ruby is too slow for programming competitions
In this context, no it's not.

One thing that Code Jam does differently (and imho better) is that they give you an input set and you have 8 minutes (or so) to upload the solution. This is expected to give more than enough space for language speed variance.

Instead of execution time, coding time is much more precious in such competitions, and

Micro-optimizing has it's place, but it's usually not in a programming competition. that's what using ruby instead of C gives you leverage for that, as you can express more complex ideas and algorithms more easily (which should be the focus point).

This doesn't mean you shouldn't know the cost of operations.

← PreviousPage 2 of 2