Skip to content

Instantly share code, notes, and snippets.

@ohesotori
Created December 18, 2016 14:20
Show Gist options
  • Save ohesotori/99cadd45f53853883c997700377ed639 to your computer and use it in GitHub Desktop.
Save ohesotori/99cadd45f53853883c997700377ed639 to your computer and use it in GitHub Desktop.
<?php
$arr = array(); $maxx = $maxy = 0;
while($line=fgets(STDIN)){
$buf = trim($line).PHP_EOL;
list($x, $y) = explode(",", $buf);
$arr[] = $buf;
$maxx = max((int)$x,$maxx); $maxy = max((int)$y,$maxy);
}
$minx = $maxx; $miny = $maxy;
foreach($arr as $buf) {
list($x, $y) = explode(",", $buf);
$minx = min((int)$x,$minx); $miny = min((int)$y,$miny);
}
$a = max(($maxx - $minx), ($maxy - $miny));
echo ($a * $a) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment