News for hackers. Stuff that matters.
Re:Can you solve it? The Greplin programming challenge by bd on Friday October 08, 2010 @04:04PM (#1773135)
"Even if you're not looking for a job, we'd love to hear what you thought about the challenge."

I would be curious how many people did you lose because of phonecall requirement (before you changed it).

Also CSV for just a list of 22 numbers wasn't really necessary.

If you do web puzzle, the best is to keep everything self-contained, no downloads, no using external channels, just copy and paste.

FYI another Python cheater here (+Wolfram Alpha & Wikipedia, I'm lazy :).

Re:Can you solve it? The Greplin programming challenge by Tichy on Friday October 08, 2010 @08:23PM (#1773962)
I just copied the CSV into the text editor. But I just realized how stupid I was. I wrote

var nums = "3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99".split(", ");

for(var i = 0;i< nums.length;i++) { nums[i] = parseInt(nums[i],10); }

Instead of just editing the numbers so that it was an array right away. Happens if you code before you think :-)

Re:Can you solve it? The Greplin programming challenge by dschoon on Friday October 08, 2010 @04:11PM (#1773164)
I don't think trivializing the combinations with Python's builtins, looking up the fib primes with OEIS, or computing factors with Alpha is cheating. I hope, in fact, it's the whole point of the exercise: choose the right tools for the job. If you're writing code to test primeness or generate Fibonacci numbers, I sure as hell don't want to hire you.
Re:Can you solve it? The Greplin programming challenge by dkarl on Friday October 08, 2010 @04:55PM (#1773349)
If you're writing code to test primeness or generate Fibonacci numbers, I sure as hell don't want to hire you.

Maybe you should have called it the "Greplin Challenge," then, instead of the "Greplin Programming Challenge." It's not a real task, after all; the reward comes from accepting a completely artificial challenge. I'm going to do the challenge before dinner tonight, and before I leave work I could get source code for the solutions from the guy down the hall from me who did the challenge as soon as it was posted -- and you certainly don't want to hire a guy who recodes other people's work for no reason, right?

Re:Can you solve it? The Greplin programming challenge by rwalker on Friday October 08, 2010 @05:35PM (#1773496)
Maybe we have a different hiring mindset than dschoon - we're equally happy with people who find the answers or create the answers. In a production system, we certainly wouldn't want hand-rolled primeness checking. But in a programming challenge, we think it's fun to write it for yourself.
Re:Can you solve it? The Greplin programming challenge by dkarl on Friday October 08, 2010 @06:09PM (#1773621)
Oops; I wrote my comment under the assumption that dschoon was with greplin, and in retrospect I'm not sure why. Sorry about that.
Re:Can you solve it? The Greplin programming challenge by zmitri on Friday October 08, 2010 @04:18PM (#1773186)
Code to generate fibs is literally one line. Remember eigenvalues :)?
Re:Can you solve it? The Greplin programming challenge by shiven on Friday October 08, 2010 @08:54PM (#1774017)
Sorry, couldn't help myself!! That approach is just so damn elegant.

int((1/math.sqrt(5))*(math.pow(((1+math.sqrt(5))/2),fibonacci)-math.pow(((1-math.sqrt(5))/2),fibonacci)))

Reference here: http://mathproofs.blogspot.com/2005/04/nth-term-of-fibonacci...

Re:Can you solve it? The Greplin programming challenge by btilly on Friday October 08, 2010 @09:30PM (#1774080)
Elegant, but inefficient if you want to get exact values for large n. You're much better off using doubling operations. If you forget those, you can remember them from the matrix version. If fib(0) = 0. fib(1) = 1. etc. Then

       n
  [0 1]  = [fib(n)   fib(n+1)]
  [1 1]    [fib(n+1) fib(n+2)]
With repeated squarings, you can efficiently generate any Fibonacci number you want.
Re:Can you solve it? The Greplin programming challenge by kasterma on Sunday October 10, 2010 @10:08AM (#1777102)
Here (where you have to search through Fibonacci numbers) I suspect memoization is rather the way to go:

  # memoized fibonacci function
  fibtable = {1:1, 0:1}

  def fib (n):
      global fibtable
      if n in fibtable.keys():
          return fibtable [n]
      val = fib (n-1) + fib (n-2)
      fibtable [n] = val
      return val
Re:Can you solve it? The Greplin programming challenge by btilly on Sunday October 10, 2010 @11:54AM (#1777237)
There is no need to keep track of all previous values.

  last_fib = 0
  fib = 1
  while fib < 225000 or not is_prime(fib):
    last_fib, fib = fib, last_fib + fib
Re:Can you solve it? The Greplin programming challenge by d0m on Friday October 08, 2010 @07:20PM (#1773826)
I tend to agree with dkarl here because if it was for real, I would just have looked here to find all the answers and maybe the passwords.

It was way more fun to do it from scratch :D

Thanks grepplin

p.s. the csv was copied in my [] python list :)

Re:Can you solve it? The Greplin programming challenge by extension on Sunday October 10, 2010 @03:58AM (#1776768)
I wrote extremely naive Ruby algos from scratch that solved the problems in a couple seconds, or in the case of the last problem, a couple of minutes. I'm sure the whole challenge would have taken longer if I tried to use any dependencies.