corrected the STUPID mistake.....WHY wrong comparator.
Added code of a fellow hacker cup guy.