From 4fb04e07c03615e0130d0d8dcdb9d3db6b26b313 Mon Sep 17 00:00:00 2001 From: drbaggy Date: Wed, 19 Jan 2022 09:26:20 +0000 Subject: pass one --- challenge-148/james-smith/perl/ch-1.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 challenge-148/james-smith/perl/ch-1.pl 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 : () } @_; +} -- cgit