Prime words

Revision as of 11:20, 4 December 2020 by CalmoSoft (talk | contribs) (Created page with "{{draft task}} A word is a prime one if its letters ASCII codes are primes. =={{header|Ring}}== <lang ring> load "stdlib.ring" cStr = read("unixdict.txt") wordList = str2list...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A word is a prime one if its letters ASCII codes are primes.

Prime words is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Ring

<lang ring> load "stdlib.ring"

cStr = read("unixdict.txt") wordList = str2list(cStr) Words = []

for n = 1 to len(wordList)

   num = 0 
   len = len(wordList[n])
   for m = 1 to len
       asc = ascii(wordList[n][m])
       if isprime(asc)
          num = num + 1
       else
          exit
       ok
   next
   if num = len and len > 2
      add(Words,wordList[n])
   ok

next

see "Prime words are:" + nl see Words </lang> Output:

Prime words are:
aaa
age
agee
ama
egg
eke
emma
gag
gage
gam
game
gamma
gee
gem
gemma
keg
mae
magma
make
mamma
meek
meg