in reply to Perl Weekly Challenge 206 with List::Util
Not from List::Util, and elegance in the eye of etc., but ...
I think slide as trivial case of natatime might fit here:
use strict; use warnings; use feature 'say'; use List::Util qw/ min pairmap /; use List::MoreUtils qw/ slide /; say min slide { $b - $a } sort { $a <=> $b } map { $_, $_ + 60 * 24 } pairmap { 60 * $a + $b } map /(\d\d):(\d\d)/, @$_ for [ qw/ 00:00 23:55 20:00 /], [ qw/ 01:01 00:50 00:57 /], [ qw/ 10:10 09:30 09:00 09:55 /] ;
(I'm so lazy I just duplicated all the clock readings to the next 24h, sorry. Second task could perhaps (?) be so more interesting for product instead of sum, if negative integers are allowed, but this is just a fleeting thought, I may be wrong)
|
|---|