News for hackers. Stuff that matters.
Re:Why 37signals Doesn't Hire Programmers Based on Brainteasers by ricardobeat on Saturday January 07, 2012 @02:16PM (#3437805)
five-minute coffee, am I hired?

    getRow = (n) ->
        rows = [[1]]
        for i in [1...n]
            prev = rows[i-1]
            rows[i] = []
            for j in [0..i]
                rows[i][j] = (prev[j-1] or 0) + (prev[j] or 0)
        rows[n-1]
and a one-liner for those who appreciate:

    (n) -> [[1]..n].reduce (p, c, i) -> ~~p[j-1] + ~~p[j] for j in [0..i]

There are no comments on this comment yet.