Prime words: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: add another variation) |
Thundergnat (talk | contribs) (→{{header|Raku}}: Get all of the ridiculousness out there so we don't have to see any more of these tasks) |
||
Line 257: | Line 257: | ||
say 'Number of words whose ords are all prime: ', |
say 'Number of words whose ords are all prime: ', |
||
@words.hyper.grep({ all(.comb |
@words.hyper.grep({ all(.comb».ord).is-prime }).&{display +$_, $_, ''}; |
||
say "\nNumber of words whose ordinal sum is prime: ", |
say "\nNumber of words whose ordinal sum is prime: ", |
||
@words.grep({ .comb».ord.sum.is-prime }).&{display +$_, .head(20)}; |
@words.grep({ .comb».ord.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».ord).is-prime && .comb».ord.sum.is-prime }).&{display +$_, $_, ''}; |
|||
say "\n\nInterpreting the words as if they were base 36 numbers:"; |
say "\n\nInterpreting the words as if they were base 36 numbers:"; |
||
Line 272: | Line 275: | ||
say "\nNumber of words whose base 36 digital sum is prime: ", |
say "\nNumber of words whose base 36 digital sum is prime: ", |
||
@words.grep({ !.contains(/\W/) && .comb».parse-base(36).sum.is-prime }).&{display +$_, .head(20)}; |
@words.grep({ !.contains(/\W/) && .comb».parse-base(36).sum.is-prime }).&{display +$_, .head(20)}; |
||
say "\nNumber of words that are prime in base 36, whose digits are all prime, and whose digital sum is prime: ", |
|||
@words.hyper.grep({ !.contains(/\W/) && all(.comb».parse-base(36)).is-prime && :36($_).is-prime && .comb».parse-base(36).sum.is-prime }).&{display +$_, $_, ''}; |
|||
use Base::Any:ver<0.1.2+>; |
use Base::Any:ver<0.1.2+>; |
||
Line 285: | Line 291: | ||
say "\nNumber of words whose digital sum is prime using a custom base 26: ", |
say "\nNumber of words whose digital sum is prime using a custom base 26: ", |
||
@words.grep({ !.contains(/<-alpha>/) && .comb».&from-base(26).sum.is-prime }).&{display +$_, .head(20)}; |
@words.grep({ !.contains(/<-alpha>/) && .comb».&from-base(26).sum.is-prime }).&{display +$_, .head(20)}; |
||
say "\nNumber of words that are prime in custom base 26, whose digits are all prime, and whose digital sum is prime: ", |
|||
@words.hyper.grep({ !.contains(/<-alpha>/) && all(.comb».&from-base(26)).is-prime && .&from-base(26).is-prime && .comb».&from-base(26).sum.is-prime }).&{display +$_, $_, ''};</lang> |
|||
{{out}} |
{{out}} |
||
<pre>Number of words whose ords are all prime: 36; |
<pre>Number of words whose ords are all prime: 36; |
||
Line 292: | Line 301: | ||
Number of words whose ordinal sum is prime: 3778; |
Number of words whose ordinal sum is prime: 3778; |
||
First 20: 10th, 9th, a, a's, aau, ababa, abate, abhorred, abject, ablate, aboard, abrade, abroad, absentee, absentia, absolute, absorptive, absurd, abusive, accelerate |
First 20: 10th, 9th, a, a's, aau, ababa, abate, abhorred, abject, ablate, aboard, abrade, abroad, absentee, absentia, absolute, absorptive, absurd, abusive, accelerate |
||
Number of words whose ords are all prime, and whose ordinal sum is prime: 12; |
|||
a, e, egg, g, gem, k, keg, m, mae, mamma, meg, q |
|||
Line 304: | Line 316: | ||
Number of words whose base 36 digital sum is prime: 4740; |
Number of words whose base 36 digital sum is prime: 4740; |
||
First 20: 10th, 3rd, 7th, aba, abacus, abalone, abase, abater, abelian, abelson, aberrant, abeyant, ablaze, abort, aboveground, abraham, abrasion, abrasive, abreact, abridge |
First 20: 10th, 3rd, 7th, aba, abacus, abalone, abase, abater, abelian, abelson, aberrant, abeyant, ablaze, abort, aboveground, abraham, abrasion, abrasive, abreact, abridge |
||
Number of words that are prime in base 36, whose digits are all prime, and whose digital sum is prime: 8; |
|||
7th, b, d, h, j, n, t, v |
|||
Line 315: | Line 330: | ||
Number of words whose digital sum is prime using a custom base 26: 5473; |
Number of words whose digital sum is prime using a custom base 26: 5473; |
||
First 20: ababa, aback, abacus, abalone, abase, abater, abc, abdicate, abdomen, abe, abelian, abelson, aberrant, abeyant, ablaze, abolish, abominate, aborigine, aboveground, abraham |
First 20: ababa, aback, abacus, abalone, abase, abater, abc, abdicate, abdomen, abe, abelian, abelson, aberrant, abeyant, ablaze, abolish, abominate, aborigine, aboveground, abraham |
||
Number of words that are prime in custom base 26, whose digits are all prime, and whose digital sum is prime: 9; |
|||
c, d, f, h, l, n, r, t, x</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |