aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2022-01-23 01:38:24 +0000
committerGitHub <noreply@github.com>2022-01-23 01:38:24 +0000
commit2d0ffcddc4a2a5536a9adfa0b6230ca17e229eff (patch)
tree98ba865a72d367f55158fcae7395ab349108b395
parent6c82ee9e3cd56bb7870416e8aee038769ccbb949 (diff)
downloadperlweeklychallenge-club-2d0ffcddc4a2a5536a9adfa0b6230ca17e229eff.tar.gz
perlweeklychallenge-club-2d0ffcddc4a2a5536a9adfa0b6230ca17e229eff.tar.bz2
perlweeklychallenge-club-2d0ffcddc4a2a5536a9adfa0b6230ca17e229eff.zip
Update ch-1.pl
-rw-r--r--challenge-148/james-smith/perl/ch-1.pl28
1 files changed, 15 insertions, 13 deletions
diff --git a/challenge-148/james-smith/perl/ch-1.pl b/challenge-148/james-smith/perl/ch-1.pl
index e306657c65..4a2d369429 100644
--- a/challenge-148/james-smith/perl/ch-1.pl
+++ b/challenge-148/james-smith/perl/ch-1.pl
@@ -8,6 +8,19 @@ use Test::More;
use Benchmark qw(cmpthese timethis);
use Data::Dumper qw(Dumper);
+## Units for which there are no "e" are used:
+## 0 [ not-spelled at all except for Zero ]
+## 2 two
+## 4 four
+## 6 six
+## Tens for which there a no "e":
+## 0 [ not-spelled at all except for Zero ]
+## 30 thirty
+## 40 forty
+## 50 fifty
+## 60 sixty
+## We only need to find 2 digit eban numbers here as there are no 3
+## digit eban numbers - hundred contains an "e"...
unless(@ARGV) {
## All eban numbers less than 1000
@@ -15,6 +28,8 @@ unless(@ARGV) {
exit;
}
+## This is the code which generates eban numbers {up to 10^18}
+
say for my@e=grep{$_}my@n=map{my$a=$_;map{10*$a+2*$_}(0..3)}(0,3..6);
for(2..$ARGV[0]){
say for@e=map{my$a=$_;map{$a*1e3+$_}@n}@e;
@@ -28,19 +43,6 @@ for(2..$ARGV[0]){
## as we have no solutions for numbers containing sextillion, septillion
## decillion to novemdecillion ..
-## Units for which there are no "e" are used:
-## 0 not-spelled at all except for Zero
-## 2
-## 4
-## 6
-## Tens for which there a no "e":
-## 0 not-spelled at all (except when 0)
-## 30
-## 40
-## 50
-## 60
-## We only need to find 2 digit eban numbers here as there are no 3
-## digit eban numbers - hundred contains an "e"...
########################################################################
## Now we extend these by adding more digits at the end so we get those