diff options
| -rwxr-xr-x | challenge-120/stuart-little/perl/ch-1.pl | 7 | ||||
| -rwxr-xr-x | challenge-120/stuart-little/perl/ch-2.pl | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-120/stuart-little/perl/ch-1.pl b/challenge-120/stuart-little/perl/ch-1.pl new file mode 100755 index 0000000000..54e4e7e5b4 --- /dev/null +++ b/challenge-120/stuart-little/perl/ch-1.pl @@ -0,0 +1,7 @@ +#!/usr/bin/env perl +use warnings; +use v5.12; + +# run <script> <number> + +say oct('0b' . (join '', map {my $rev = reverse substr(sprintf("%08b", $ARGV[0] & 255), 2*$_,2)} (0..3))) diff --git a/challenge-120/stuart-little/perl/ch-2.pl b/challenge-120/stuart-little/perl/ch-2.pl new file mode 100755 index 0000000000..beeeee77af --- /dev/null +++ b/challenge-120/stuart-little/perl/ch-2.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env perl +use warnings; +use v5.12; + +# run <script> <time> + +use feature qw(signatures); +no warnings qw(experimental::signatures); + +sub angl($h,$m) { + my $rawDiff = abs(($h % 12)*30 + $m/2 - $m * 6); + return ($rawDiff <= 180) ? ($rawDiff) : (360-$rawDiff); +} + +say angl(split ":", $ARGV[0]); |
