Eban numbers: Difference between revisions
→{{header|Perl 6}}: Simplify, fix problem with irregulars (didn't affect e-bans as all irregulars contain an e)
m (→{{header|zkl}}: reformat) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Simplify, fix problem with irregulars (didn't affect e-bans as all irregulars contain an e)) |
||
Line 430:
Considering numbers up to <strong>10<sup>21</sup></strong>, as the task directions suggest.
<lang perl6>use Lingua::EN::Numbers;
sub nban ($seq, $n = 'e') { ($seq).map: { next if .&cardinal.contains(any($n.lc.comb)); $_ } }
Line 439:
(2 .. $upto).map: -> $o {
given $o % 3 { # Compensate for irregulars: 11 - 19
when
default {
}
}
^@orders .map: -> $o {
@ban.push: [] and next unless +@orders[$o];
my @these;
@these.push: $m;
for ^@ban -> $b {
next unless +@ban[$b];
@these.push: $_ for (flat @ban[$b]) »+» $m ;
}
}
@ban.push: @these;
}
@ban.unshift(0) if nban(0, $n);
flat @ban.map: *.flat;
Line 482 ⟶ 463:
(2 .. $upto).map: -> $o {
given $o % 3 { # Compensate for irregulars: 11 - 19
when
default {
}
}
my @count = +nban(1 .. 99, $n);
^@orders .map: -> $o {
@count.push: 0 and next unless +@orders[$o];
my
my $sum = @count.sum;
my $these = +@
$these-- if $prev;
@count[1 + $o] += $these;
++@count[$o] if $prev;
}
++@count[0] if nban(0, $n);
[\+] @count;
Line 579 ⟶ 548:
Up to and including one million: 57
Up to and including ten million: 392
Up to and including one hundred million:
Up to and including one billion:
Up to and including ten billion:
Up to and including one hundred billion:
Up to and including one trillion:
Up to and including ten trillion:
Up to and including one hundred trillion:
Up to and including one quadrillion:
Up to and including ten quadrillion:
Up to and including one hundred quadrillion:
Up to and including one quintillion:
Up to and including ten quintillion:
Up to and including one hundred quintillion:
Up to and including one sextillion:
============= subur-ban: =============
Line 608 ⟶ 577:
Up to and including one hundred thousand: 35
Up to and including one million: 36
Up to and including ten million:
Up to and including one hundred million:
Up to and including one billion:
Up to and including ten billion:
Up to and including one hundred billion:
Up to and including one trillion:
Up to and including ten trillion:
Up to and including one hundred trillion:
Up to and including one quadrillion:
Up to and including ten quadrillion:
Up to and including one hundred quadrillion:
Up to and including one quintillion:
Up to and including ten quintillion:
Up to and including one hundred quintillion:
Up to and including one sextillion:
Note that the limit to one sextillion is somewhat arbitrary and is just to match the task parameters.
|