aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-035/roger-bell-west/perl5/ch-1.pl78
-rwxr-xr-xchallenge-035/roger-bell-west/perl5/ch-2.pl74
-rwxr-xr-xchallenge-035/roger-bell-west/perl5/corrupt.pl16
-rwxr-xr-xchallenge-035/roger-bell-west/perl6/ch-1.p670
-rwxr-xr-xchallenge-035/roger-bell-west/perl6/ch-2.p666
5 files changed, 304 insertions, 0 deletions
diff --git a/challenge-035/roger-bell-west/perl5/ch-1.pl b/challenge-035/roger-bell-west/perl5/ch-1.pl
new file mode 100755
index 0000000000..dc7dc40f83
--- /dev/null
+++ b/challenge-035/roger-bell-west/perl5/ch-1.pl
@@ -0,0 +1,78 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+my %t;
+while (<DATA>) {
+ chomp;
+ /^(.) (.*)$/;
+ $t{$1}=$2;
+}
+
+my %e;
+foreach my $char (keys %t) {
+ $e{$char}=join('0',map {{'.' => '1',
+ '_' => '111'}->{$_}}
+ split '',$t{$char});
+}
+
+my $chars=join('',keys %t);
+
+my @in;
+while (<>) {
+ chomp;
+ my $t=uc($_);
+ $t =~ s/[^ $chars]//g;
+ push @in,$t;
+}
+
+my $m=join(' ',@in);
+
+my @l;
+foreach my $word (split ' ',$m) {
+ my @w;
+ foreach my $char (split '',$word) {
+ push @w,$e{$char};
+ }
+ push @l,join('000',@w);
+}
+print join('000000',@l),"\n";
+
+__DATA__
+E .
+I ..
+S ...
+H ....
+5 .....
+4 ...._
+V ..._
+3 ...__
+U .._
+F .._.
+2 ..___
+A ._
+R ._.
+L ._..
+W .__
+P .__.
+J .___
+1 .____
+T _
+N _.
+D _..
+B _...
+6 _....
+X _.._
+K _._
+C _._.
+Y _.__
+M __
+G __.
+Z __..
+7 __...
+Q __._
+O ___
+8 ___..
+9 ____.
+0 _____
diff --git a/challenge-035/roger-bell-west/perl5/ch-2.pl b/challenge-035/roger-bell-west/perl5/ch-2.pl
new file mode 100755
index 0000000000..635f1f598d
--- /dev/null
+++ b/challenge-035/roger-bell-west/perl5/ch-2.pl
@@ -0,0 +1,74 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+my %t;
+while (<DATA>) {
+ chomp;
+ /^(.) (.*)$/;
+ $t{$1}=$2;
+}
+
+my %d;
+foreach my $char (keys %t) {
+ $d{join('0',map {{'.' => '1',
+ '_' => '111'}->{$_}}
+ split '',$t{$char})}=$char;
+}
+
+my @in;
+while (<>) {
+ chomp;
+ push @in,$_;
+}
+
+my $m=join('',@in);
+
+my @m;
+foreach my $word (split /000000+/,$m) {
+ my @w;
+ foreach my $char (split /000+/,$word) {
+ push @w,($d{$char} or '?');
+ }
+ push @m,join('',@w);
+}
+print join(' ',@m),"\n";
+
+__DATA__
+E .
+I ..
+S ...
+H ....
+5 .....
+4 ...._
+V ..._
+3 ...__
+U .._
+F .._.
+2 ..___
+A ._
+R ._.
+L ._..
+W .__
+P .__.
+J .___
+1 .____
+T _
+N _.
+D _..
+B _...
+6 _....
+X _.._
+K _._
+C _._.
+Y _.__
+M __
+G __.
+Z __..
+7 __...
+Q __._
+O ___
+8 ___..
+9 ____.
+0 _____
diff --git a/challenge-035/roger-bell-west/perl5/corrupt.pl b/challenge-035/roger-bell-west/perl5/corrupt.pl
new file mode 100755
index 0000000000..9712f951b4
--- /dev/null
+++ b/challenge-035/roger-bell-west/perl5/corrupt.pl
@@ -0,0 +1,16 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+while (<>) {
+ chomp;
+ my $t=$_;
+ foreach (0..int(rand()*length($t)/2)) {
+ substr($t,
+ int(rand()*length($t)),
+ 1,
+ (rand()<0.5)?'0':'1');
+ }
+ print "$t\n";
+}
diff --git a/challenge-035/roger-bell-west/perl6/ch-1.p6 b/challenge-035/roger-bell-west/perl6/ch-1.p6
new file mode 100755
index 0000000000..cc976f2f63
--- /dev/null
+++ b/challenge-035/roger-bell-west/perl6/ch-1.p6
@@ -0,0 +1,70 @@
+#! /usr/bin/perl6
+
+my %t=(
+ E => '.',
+ I => '..',
+ S => '...',
+ H => '....',
+ 5 => '.....',
+ 4 => '...._',
+ V => '..._',
+ 3 => '...__',
+ U => '.._',
+ F => '.._.',
+ 2 => '..___',
+ A => '._',
+ R => '._.',
+ L => '._..',
+ W => '.__',
+ P => '.__.',
+ J => '.___',
+ 1 => '.____',
+ T => '_',
+ N => '_.',
+ D => '_..',
+ B => '_...',
+ 6 => '_....',
+ X => '_.._',
+ K => '_._',
+ C => '_._.',
+ Y => '_.__',
+ M => '__',
+ G => '__.',
+ Z => '__..',
+ 7 => '__...',
+ Q => '__._',
+ O => '___',
+ 8 => '___..',
+ 9 => '____.',
+ 0 => '_____',
+);
+
+my %e;
+for keys %t -> $char {
+ %e{$char}=join('0',map {{'.' => '1',
+ '_' => '111'}.{$_}},
+ grep /./,
+ split '',%t{$char});
+}
+
+my $chars=join('',keys %t);
+
+my @in;
+for lines() {
+ .chomp;
+ my $t=uc($_);
+ $t ~~ s:g/[^ $chars]//;
+ push @in,$t;
+}
+
+my $m=join(' ',@in);
+
+my @l;
+for grep /./,split ' ',$m -> $word {
+ my @w;
+ for grep /./,split '',$word -> $char {
+ push @w,%e{$char};
+ }
+ push @l,join('000',@w);
+}
+print join('000000',@l),"\n";
diff --git a/challenge-035/roger-bell-west/perl6/ch-2.p6 b/challenge-035/roger-bell-west/perl6/ch-2.p6
new file mode 100755
index 0000000000..f78f91fbbd
--- /dev/null
+++ b/challenge-035/roger-bell-west/perl6/ch-2.p6
@@ -0,0 +1,66 @@
+#! /usr/bin/perl6
+
+my %t=(
+ E => '.',
+ I => '..',
+ S => '...',
+ H => '....',
+ 5 => '.....',
+ 4 => '...._',
+ V => '..._',
+ 3 => '...__',
+ U => '.._',
+ F => '.._.',
+ 2 => '..___',
+ A => '._',
+ R => '._.',
+ L => '._..',
+ W => '.__',
+ P => '.__.',
+ J => '.___',
+ 1 => '.____',
+ T => '_',
+ N => '_.',
+ D => '_..',
+ B => '_...',
+ 6 => '_....',
+ X => '_.._',
+ K => '_._',
+ C => '_._.',
+ Y => '_.__',
+ M => '__',
+ G => '__.',
+ Z => '__..',
+ 7 => '__...',
+ Q => '__._',
+ O => '___',
+ 8 => '___..',
+ 9 => '____.',
+ 0 => '_____',
+);
+
+my %d;
+for keys %t -> $char {
+ %d{join('0',map {{'.' => '1',
+ '_' => '111'}.{$_}},
+ grep /./,
+ split '',%t{$char})}=$char;
+}
+
+my @in;
+for lines() {
+ .chomp;
+ push @in,$_;
+}
+
+my $m=join('',@in);
+
+my @m;
+for grep /./,split /000000+/,$m -> $word {
+ my @w;
+ for grep /./,split /000+/,$word -> $char {
+ push @w,(%d{$char} or '?');
+ }
+ push @m,join('',@w);
+}
+print join(' ',@m),"\n";