PHP and Javascript solutions to hard challenge #51 - Closest Pairs