diff options
| author | drbaggy <js5@sanger.ac.uk> | 2022-01-19 09:26:20 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2022-01-19 09:26:20 +0000 |
| commit | 4fb04e07c03615e0130d0d8dcdb9d3db6b26b313 (patch) | |
| tree | 6debf9f7e7b9d3edff64c4498dc919cfbc0780e6 | |
| parent | 5bd157274f9d0377833a954cf48d6b4866615aae (diff) | |
| download | perlweeklychallenge-club-4fb04e07c03615e0130d0d8dcdb9d3db6b26b313.tar.gz perlweeklychallenge-club-4fb04e07c03615e0130d0d8dcdb9d3db6b26b313.tar.bz2 perlweeklychallenge-club-4fb04e07c03615e0130d0d8dcdb9d3db6b26b313.zip | |
pass one
| -rw-r--r-- | challenge-148/james-smith/perl/ch-1.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-148/james-smith/perl/ch-1.pl b/challenge-148/james-smith/perl/ch-1.pl new file mode 100644 index 0000000000..ade1c05955 --- /dev/null +++ b/challenge-148/james-smith/perl/ch-1.pl @@ -0,0 +1,23 @@ +#!/usr/local/bin/perl + +use strict; + +use warnings; +use feature qw(say); +use Test::More; +use Benchmark qw(cmpthese timethis); +use Data::Dumper qw(Dumper); + +my $N = @ARGV ? $ARGV[0] : 1; +## works for $N up 5... +my @digits = (0,2,4,6); +my @tens = (0,30,40,50,60); +my @three_digit_eban_nos = map { my $a=$_; map { $a+$_ } @digits } @tens; + +dump_list( my @next_order = grep {$_} @three_digit_eban_nos ); +dump_list( @next_order = map { my $a = $_; map { sprintf "%s,%03d", $a,$_ } @three_digit_eban_nos } @next_order ) + for 2..$N; + +sub dump_list { + say $_ foreach map { $_ ? s{^0+}{}r : () } @_; +} |
