aboutsummaryrefslogtreecommitdiff
path: root/challenge-076/james-smith
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-07-04 21:10:19 +0100
committerdrbaggy <js5@sanger.ac.uk>2022-07-04 21:10:19 +0100
commit251b2bd8b0ff8d3b1262173c33a4e999cf37846a (patch)
treee6d58a6a75f6a895cb07762b0183860f48096b9d /challenge-076/james-smith
parent9a0e9aa937cd71b048889a57f68896e5187466ac (diff)
downloadperlweeklychallenge-club-251b2bd8b0ff8d3b1262173c33a4e999cf37846a.tar.gz
perlweeklychallenge-club-251b2bd8b0ff8d3b1262173c33a4e999cf37846a.tar.bz2
perlweeklychallenge-club-251b2bd8b0ff8d3b1262173c33a4e999cf37846a.zip
new stuff
Diffstat (limited to 'challenge-076/james-smith')
-rw-r--r--challenge-076/james-smith/perl/ch-2.pl32
1 files changed, 25 insertions, 7 deletions
diff --git a/challenge-076/james-smith/perl/ch-2.pl b/challenge-076/james-smith/perl/ch-2.pl
index 2348c8b946..b11525b5d5 100644
--- a/challenge-076/james-smith/perl/ch-2.pl
+++ b/challenge-076/james-smith/perl/ch-2.pl
@@ -8,13 +8,31 @@ use Test::More;
use Benchmark qw(cmpthese timethis);
use Data::Dumper qw(Dumper);
-my @TESTS = (
- [ 0, 1 ],
-);
-
-is( my_function($_->[0]), $_->[1] ) foreach @TESTS;
-
-done_testing();
+open my $fh, '<', 'grid.txt';
+my @G;
+(chomp, push @G, [ split ]) while(<$fh>);
+close $fh;
+my @lines = map { join '', @{$_} } @G;
+foreach my $i ( 0..@{$G[0]}-1 ) {
+ push @lines, join '', map { $_->[$i] } @G;
+}
+my $size = @G > @{$G[0]} ? @G : @{$G[0]};
+foreach my $i ( 0..$size-1 ) {
+ unless($i >= @G) {
+ unless( $i >= @{$G[0]} ) {
+ push @lines, join '', map { $G[$i][$i+$_] } 0..$size-$i-1;
+ }
+ push @lines, join '', map { $G[$i][$i-$_] } 0..$i;
+ }
+ unless($i >= @{$G[0]}) {
+ unless( $i >= @G ) {
+ push @lines, join '', map { $G[$i+$_][$i] } 0..$size-$i-1;
+ }
+ push @lines, join '', map { $G[$i-$_][$i] } 0..$i;
+ }
+}
+push @lines, map { reverse $_ } @lines;
+say for @lines;
sub my_function {
return 1;