Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Perl Weekly Challenge 206 -- oneliner

by Discipulus (Canon)
on Mar 18, 2023 at 09:55 UTC ( [id://11151052] : note . print w/replies, xml ) Need Help??


in reply to Perl Weekly Challenge 206 with List::Util

Just for fun and with many doubts on my own working solution, a nice oneliner for the first challange on time differences

perl -le "@v=sort{push@r,abs$a-$b;$a-$b}map{($h,$m)=split':',$_;$M=60* +$h+$m;($M,$M+1440,$M+2880)}@ARGV;print+(sort{$a<=>$b}@r)[0]" @ARGV = 00:00 23:55 20:00 => 5 @ARGV = 01:01 00:50 00:57 => 4 @ARGV = 10:10 09:30 09:00 09:55 => 15

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.