Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Most isolated of 3 points

Perl, 147 bytes Reads list of points from stdin. Prints chosen point. perl -ple'@P=/\d+/g;($c,$a,$b)=map{$p=($_+2)%6;($P[$_]-$P[$p])**2+($P[$_+1]-$P[$p+1])**2}0,2,4;$p=$c>$b?$b>$a?0:2:$c&gt...

posted 6mo ago by jhnc‭

Answer
#1: Initial revision by user avatar jhnc‭ · 2026-03-10T23:16:27Z (6 months ago)
# Perl, 147 bytes

Reads list of points from stdin. Prints chosen point.

```
perl -ple'@P=/\d+/g;($c,$a,$b)=map{$p=($_+2)%6;($P[$_]-$P[$p])**2+($P[$_+1]-$P[$p+1])**2}0,2,4;$p=$c>$b?$b>$a?0:2:$c>$a?0:4;$_=join",",@P[$p,$p+1]'
```

Comments:
```
perl -ple'
    # load input
    @P=/\d+/g;

    # compute distances
    ($c,$a,$b) = map {
        $p = ($_+2)%6;
        ($P[$_]-$P[$p])**2 + ($P[$_+1]-$P[$p+1])**2
    } 0,2,4;

    # choose appropriate index into point list
    $p = $c>$b
         ? $b>$a ? 0 : 2
         : $c>$a ? 0 : 4
       ;

    # display
    say join ",", @P[$p,$p+1]
'
```

[Try it online!][TIO-mml86uw4]

[TIO-mml86uw4]: https://tio.run/##XVPbbhpBDH33V6zoRgrBKDv3mUUk@YS8NxGClLRUKayAt9JfL/XxoAj1ZTw@vhz7zO6w3n@E85fmfbdvjuvDsfmx3G/XhwMN@832@N6Mbg7N9KEZcbuYnZ@e5/cv3yb332e37Ru3S25X4/mv5fC7Hea37WJixzdRQs9f28XrFGZ4Hd/d2UmFJuYCygXwn44t@5nUtm8P7eqxXT20y8eutz183CS4mP/cbbYjHvETSlmrz2fHrpk1ho2cTs6@AXJS5ASErjMs2/8yBCF3qXZXGbXaXTLMZwx5yBCEnPrX3HKnon7mIGdgL2jRKZCbOH3myp2iZnmNFeHoGyAnRU5AhLloN2REufe4C0dWPylHUY5MIqJyBJ0qKUeQ3KhZ6WqeeEGjzloUlTslZbPaoSohiEyZNctcTZkph9rCqzYlsMEccCmwxSTOamHy7CNawZKL7HKVESyuq0G4FDt2KCwytw4tWyGolkxij/Gc9IEctuPYoRQ@Gc@mq6Rqk@ikrLCUOYLUirwI5swJO6slK@1tLYlRtcuuVsZIwXDEoKXjgNki1OjVUJYPV3fJXLSB4xzQFjg5eTuIbgxbkJrCAY@iOGXHXvuK7koakd1XSyJnKBcJ9eHkHbCr4lDC1Y8apw/oXz9J4dJuqbDFRNkzRFAY0uvHVKqOUpewCmARKGgveXv9UXKNAaaU2AL0vj6dNFVC9UmUCPrMsghaxMQZ2qpPcuqa1uKdZSFXlVec/u6G42a3PZynw8c/ "Perl 5 – Try It Online"