News for hackers. Stuff that matters.
Re:Why 37signals Doesn't Hire Programmers Based on Brainteasers by nileshtrivedi on Friday January 06, 2012 @01:24AM (#3432265)
Here is my version. Took me less than 5 minutes and worked the first time:

  def pascal(num)
    return [1] if num == 1
    res = []
    prev = [0] + pascal(num-1) + [0]
    (1..num).to_a.each { |i| res << (prev[i-1] + prev[i]) }
    return res
  end
Re:Why 37signals Doesn't Hire Programmers Based on Brainteasers by mbernstein on Friday January 06, 2012 @02:03AM (#3432358)
Recursion in this case - generally in ruby as well - is not a great idea. Also, you have quite high memory requirements: O(n^2)

O(n) is quite easy in this problem.