Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
install faster perl6 version
This version is twice as fast and cheats more like the nqp version.
  • Loading branch information
TimToady committed Aug 14, 2014
1 parent 68f3ffe commit af4e774
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions perl6/rc-self-describing-numbers
@@ -1,8 +1,14 @@
sub is_selfdesc($n) {
my @b = 0 xx $n.chars;
@b[$_]++ for my @a = $n.comb;
@b[$_] //= 0 for ^@b;
@a eq @b;
my $s = $n.Str;
my $chars = $s.chars;
my @a = +«$s.comb;
my @b;
for @a -> $i {
return False if $i >= $chars;
++@b[$i];
}
@b[$_] //= 0 for ^$chars;
@a eqv @b;
}

# check all numbers from 0 to SCALE
Expand Down

0 comments on commit af4e774

Please sign in to comment.