Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function Distance($x1, $y1, $x2, $y2)
- {
- return sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
- }
- list($x1, $y1, $x2, $y2, $x3, $y3) = explode(", ", trim(fgets(STDIN)));
- $d['a'] = Distance($x1, $y1, $x2, $y2);
- $d['b'] = Distance($x2, $y2, $x3, $y3);
- $d['c'] = Distance($x1, $y1, $x3, $y3);
- asort($d);
- //print_r($d);
- $n = array_slice($d,0,2, true);
- ksort($n);
- $k = array_keys($n);
- $sum = $n[$k[0]]+$n[$k[1]];
- //print_r($n);
- //print_r($k);
- if (!array_key_exists('a',$n)){
- echo "1->3->2";
- }
- if (!array_key_exists('b',$n)){
- echo "2->1->3";
- }
- if (!array_key_exists('c',$n)){
- echo "1->2->3";
- }
- echo ": $sum";
Advertisement
Add Comment
Please, Sign In to add comment