Prime words: Difference between revisions

Content added Content deleted
(Added Go)
m (→‎{{header|Raku}}: typos, tweaks)
Line 255: Line 255:


say 'Number of words whose ords are all prime: ',
say 'Number of words whose ords are all prime: ',
@words.map({ next unless all(.comb.».ord).is-prime; $_ }).&{"{+$_};\n{.join: ', '}"};
@words.hyper.map({ next unless all(.comb.».ord).is-prime; $_ }).&{"{+$_};\n{.join: ', '}"};


say "\nNumber of words whose ordinal sum is prime: ",
say "\nNumber of words whose ordinal sum is prime: ",
@words.map({ $_ if .comb».ord.sum.is-prime }).&{"{+$_};\nFirst 20: {.head(20).join: ', '} ..."};
@words.map({ $_ if .comb».ord.sum.is-prime }).&{"{+$_};\nFirst 20: {.head(20).join: ', '} ..."};


say "\n\nIterpreting the words as if they were base 36 numbers:";
say "\n\nInterpreting the words as if they were base 36 numbers:";


say "\nNumber of words that are prime in base 36: ",
say "\nNumber of words that are prime in base 36: ",
Line 274: Line 274:


say "\nNumber of words whose 'digits' are all prime using a custom base: ",
say "\nNumber of words whose 'digits' are all prime using a custom base: ",
@words.map({ next if .contains(/<-alpha>/); $_ if all(.comb».&from-base(26)).is-prime }).&{"{+$_};\n{.join: ', '}"};
@words.hyper.map({ next if .contains(/<-alpha>/); $_ if all(.comb».&from-base(26)).is-prime }).&{"{+$_};\n{.join: ', '}"};


say "\nNumber of words that are prime using a custom base: ",
say "\nNumber of words that are prime using a custom base: ",
Line 289: Line 289:




Iterpreting the words as if they were base 36 numbers:
Interpreting the words as if they were base 36 numbers:


Number of words that are prime in base 36: 1106;
Number of words that are prime in base 36: 1106;