Live data from Hacker News

Can you solve it? The Greplin programming challenge

challenge.greplin.com

71–80 of 167 posts

Re: Can you solve it? The Greplin programming challenge

#74
post #31
post #23

So what languages did everyone use? I decided to try a different one on each level, so I used Python, bash (letting GNU coreutils 'factor' do the hard work), and Haskell, respectively.

Ruby was my main choice + some command line tools to do bits of extra work, like 'sort' to find the largest palindrome and 'wc' to count the results in last exercise, and even Python command line to just manually sum the primes in second exercise.

Ruby has Array#sort, no command line required.

Re: Can you solve it? The Greplin programming challenge

#75
post #62

Python powerset() with max(), list.remove(), and sum() builtins made the last problem's solution ~5 lines long :)

I don't know about powerset(), but challenge 3 was pretty trivial using Python's itertools module: http://gist.github.com/617663 (warning: spoilers)

Re: Can you solve it? The Greplin programming challenge

#76
post #23

So what languages did everyone use? I decided to try a different one on each level, so I used Python, bash (letting GNU coreutils 'factor' do the hard work), and Haskell, respectively.

Clojure here.

Mind posting your solution as a Gist? I want to see how to do level 1 without explicit loops or variables.

Re: Can you solve it? The Greplin programming challenge

#77
post #19

Anybody else browsing by mobile try to do Level 1 by inspection?

Brute works here because of bad test case. Author could have generated a smart test case and then optimal algorithm could be using suffix array which takes O(n), brute would take O(n!). However a bit smart brute gave the answer in approx 3-4 minutes ( computation + coding time). And yes, Python FTW.

3-4min? Since it was only like 5 lines of code I did it in brute force. Python and Mac Mini here - the answer came almost instantaneously.

Re: Can you solve it? The Greplin programming challenge

#80
post #47

That was fun, good waste of time while my code was compiling. I just used C++ and hacked up a prime seive for #2 and for #3 used a combination generator I had previously used before - http://photon.poly.edu/~hbr/boost/combinations.html

for #3 used a combination generator Congratulations, you just used an exponential-time algorithm for a polynomial-time problem.

Congratulations are in order, he sacrificed 400ms CPU time to save at least a few minutes of coding time.
Post reply on HN