News for hackers. Stuff that matters.
Re:Can you solve it? The Greplin programming challenge by cperciva on Friday October 08, 2010 @05:36PM (#1773504)
for #3 used a combination generator

Congratulations, you just used an exponential-time algorithm for a polynomial-time problem.

Re:Can you solve it? The Greplin programming challenge by Deestan on Friday October 08, 2010 @06:37PM (#1773712)
Congratulations are in order, he sacrificed 400ms CPU time to save at least a few minutes of coding time.
Re:Can you solve it? The Greplin programming challenge by cperciva on Friday October 08, 2010 @07:22PM (#1773832)
I wasn't being entirely sarcastic. It never occurred to me that you could use a non-polynomial-time algorithm.
Re:Can you solve it? The Greplin programming challenge by util on Monday October 11, 2010 @03:19AM (#1779046)
All the solutions posted here seem to involve generating all subsequences. Could you say more about your approach?
Re:Can you solve it? The Greplin programming challenge by dsc on Friday October 08, 2010 @11:37PM (#1774276)
Not always is "exponential" a bad thing. For small sets, the expo algorithm is actually faster than the polynomial one. Although yeah, generally speaking, it's a bad idea.
Re:Can you solve it? The Greplin programming challenge by ay on Sunday October 10, 2010 @08:45AM (#1777017)
I tried on #3 the most inefficient algorithm I could come up with - blindly going through all possible combinations and checking if their biggest member is equal to the sum of the rest. Time of the execution: 0.6s

I am not sure if this step of allowing the "shortcuts" was part of the game or not. All that would had to be done is to give 128 elements of the array to exclude at least the most blatant brute-forcing.