Prime words: Difference between revisions

→‎{{header|Raku}}: add some comments to separate the task from the variants
(→‎{{header|Raku}}: add some comments to separate the task from the variants)
Line 271:
sub display ($n, @n, $s = "First 20: ") {"$n;\n{$s}{@n.join: ', '}"}
 
# The task
say 'Number of words whose ords are all prime: ',
@words.hyper.grep({ all(.comb»ords.ord)all.is-prime }).&{display +$_, $_, ''};
 
# Twelve other minor variants
say "\nNumber of words whose ordinal sum is prime: ",
@words.grep({ .comb».ordords.sum.is-prime }).&{display +$_, .head(20)};
 
say "\nNumber of words whose ords are all prime, and whose ordinal sum is prime: ",
@words.hyper.grep({ all(.comb»ords.ord)all.is-prime && .comb».ordords.sum.is-prime }).&{display +$_, $_, ''};
 
say "\n\nInterpreting the words as if they were base 36 numbers:";
10,327

edits