Square detection program I wrote for Facebook Hackers cup qualifier