Facebook hackercup - problem solution in javascript | Hacker News Reader