Can you solve it? The Greplin programming challenge
71–80 of 167 posts
Re: Can you solve it? The Greplin programming challenge
#72Re: Can you solve it? The Greplin programming challenge
#73Re: Can you solve it? The Greplin programming challenge
#74So 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.
Re: Can you solve it? The Greplin programming challenge
#75Python powerset() with max(), list.remove(), and sum() builtins made the last problem's solution ~5 lines long :)
Re: Can you solve it? The Greplin programming challenge
#76So 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.
Re: Can you solve it? The Greplin programming challenge
#77Anybody 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.
Re: Can you solve it? The Greplin programming challenge
#78Any improvements welcome!
(warning - contains the answers!)
Re: Can you solve it? The Greplin programming challenge
#79Ruby solutions to #1 and #2: http://gist.github.com/617676 http://gist.github.com/617678
Re: Can you solve it? The Greplin programming challenge
#80That 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.