Eban numbers: Difference between revisions
m
→{{header|Perl 6}}: minor style twiddles
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Fix fence-post error. Auto-adjust string width.) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: minor style twiddles) |
||
Line 268:
sub nban ($seq, $n = 'e') { ($seq).map: { next if .&cardinal.contains(any($n.comb)); $_ } }
sub
my @ban = flat ((1 .. 99),).map: *.&nban($n);
my @orders = (2 ..
for @orders -> @order {
next unless +@order;
Line 283:
sub count ($n, $upto) {
my @orders = (2 .. $upto).map({ 10**$_ X* 1..9 }).map: *.&nban($n);
my @count =
@count.push: @count.sum * @orders[$_] + @orders[$_] for ^(+@orders - 1);
@count[0] += 1 if 0.&nban($n);
Line 295:
for < e t subur > -> $n { # An assortment for demonstration
my $upto = 21; # 1e21
my @bans =
my @counts = count($n, $upto);
Line 306:
"\nCounts of {$n}-ban numbers up to {cardinal 10**$upto}"
;
my $s = max ( ^$upto).map: {(10**$_).&cardinal.chars };
@counts.unshift: @bans.first: * > 10, :k;
for @counts.kv -> $k, $c {
|