aboutsummaryrefslogtreecommitdiff
path: root/challenge-002/james-smith/perl5
diff options
context:
space:
mode:
authorbagheera-sands <git@sandsscouts.org.uk>2019-04-03 23:08:31 +0100
committerbagheera-sands <git@sandsscouts.org.uk>2019-04-03 23:08:31 +0100
commit9a2b0d4d705046ff50f9ec0a3e953fd5ed62518f (patch)
tree8ddb0ccfefa3cd54f3e294ec759d31b9713c2c59 /challenge-002/james-smith/perl5
parent9806a0cead89d364cf0b5ec1e01459eb372a77d2 (diff)
downloadperlweeklychallenge-club-9a2b0d4d705046ff50f9ec0a3e953fd5ed62518f.tar.gz
perlweeklychallenge-club-9a2b0d4d705046ff50f9ec0a3e953fd5ed62518f.tar.bz2
perlweeklychallenge-club-9a2b0d4d705046ff50f9ec0a3e953fd5ed62518f.zip
fixes to do 2nd half of problem and to use currying in perl6
Diffstat (limited to 'challenge-002/james-smith/perl5')
-rw-r--r--challenge-002/james-smith/perl5/ch-2.pl16
1 files changed, 7 insertions, 9 deletions
diff --git a/challenge-002/james-smith/perl5/ch-2.pl b/challenge-002/james-smith/perl5/ch-2.pl
index e807b1731a..a7922d205f 100644
--- a/challenge-002/james-smith/perl5/ch-2.pl
+++ b/challenge-002/james-smith/perl5/ch-2.pl
@@ -1,13 +1,11 @@
use strict;
+use v5.26;
-sub base35 {
- my $o = '';
- for( shift; $_; ) {
- $_ = ( $_ - (my $t = $_%35) )/ 35;
- $o .= chr $t+($t<10?48:55);
- }
- return scalar reverse $o;
-}
+sub r35 {$_[0]?r35(substr $_[0],0,-1)*35+z(substr $_[0],-1):0}
+sub b35 {$_[0]?b35(int$_[0]/35).x($_[0]%35):''}
+sub x {chr$_[0]+($_[0]<10?48:55)}
+sub z {(ord$_[0])-($_[0]=~/\d/?48:55)}
-print $_,"\t", base35( $_ ),"\n" foreach @ARGV;
+say b35 $_ for @ARGV;
+say r35 b35 $_ for @ARGV;