aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-20 21:10:27 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-20 21:10:27 +0100
commit1350703485b89cc217bc8c4a2a782ff61d085bb9 (patch)
treedb7694203892afcbc0166b5684bff767af8fc032
parent268826bcb6ba3cc51e6639e3c3414e66a0051261 (diff)
downloadperlweeklychallenge-club-1350703485b89cc217bc8c4a2a782ff61d085bb9.tar.gz
perlweeklychallenge-club-1350703485b89cc217bc8c4a2a782ff61d085bb9.tar.bz2
perlweeklychallenge-club-1350703485b89cc217bc8c4a2a782ff61d085bb9.zip
- Updated Perl solution to task 2 of week 120 by Ulrich Rieke.
-rw-r--r--challenge-120/ulrich-rieke/perl/ch-2.pl21
1 files changed, 13 insertions, 8 deletions
diff --git a/challenge-120/ulrich-rieke/perl/ch-2.pl b/challenge-120/ulrich-rieke/perl/ch-2.pl
index 5a8341f4b1..72a51fa695 100644
--- a/challenge-120/ulrich-rieke/perl/ch-2.pl
+++ b/challenge-120/ulrich-rieke/perl/ch-2.pl
@@ -1,9 +1,14 @@
-use v6 ;
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
-sub MAIN( Str $T is copy ) {
- my ( $hours, $minutes ) = $T.split( /':'/ ) ;
- my $hourposition = 360 / 12 * (+$hours % 12 ) + 30 / 60 * $minutes ;
- my $minutesposition = 360 / 60 * $minutes ;
- say ( max( $hourposition, $minutesposition ) - min( $hourposition ,
- $minutesposition ) ) ~ " degrees" ;
-}
+my $T = $ARGV[0] ;
+my ( $hours , $minutes ) = split( /:/ , $T ) ;
+my $hourPosition = 360 / 12 * ($hours % 12 ) + 30 / 60 * $minutes ;
+my $minutesPosition = 360 / 60 * $minutes ;
+my $max = $hourPosition > $minutesPosition ? $hourPosition :
+$minutesPosition ;
+my $min = $hourPosition > $minutesPosition ? $minutesPosition :
+$hourPosition ;
+say $max - $min . " degrees" ;