trying to solve facebook hacker cup problem