We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
<?php$_fp=fopen("php://stdin","r");$input=stream_get_contents($_fp);$lines=preg_split('/\R/',$input);// Remove first linearray_shift($lines);$pattern='/^\([\+\-]?(90(?:\.0+)?|[0-8]?\d(?:\.\d+)?),\s?[\+\-]?(180(?:\.0+)?|(?:1?[0-7]\d|0?\d?\d)(?:\.\d+)?)\)$/';foreach($linesas$line){// Check each line$result=preg_match($pattern,$line)?'Valid':'Invalid';echo$result.PHP_EOL;}?>
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Detecting Valid Latitude and Longitude Pairs
You are viewing a single comment's thread. Return to all comments →
PHP solution: