Code Comparison
What are some words that remain words when 'r's are added to them, and what words do they become?
J
The original attempt.
words =: (#~ 5 < #@>) 'b' fread '/usr/share/dict/words'
r =: (#~ ('r' e. >)"0) (#~ ('r' -.@e. _2 {. >)"0) words
n =: (-.&'rR') &.> r
r =: r #~ n e. words
n =: n #~ n e. words
({~ 10 ? #) n,.r
┌────────────┬─────────────┐
│evolutionist│revolutionist│
├────────────┼─────────────┤
│pokiness │porkiness │
├────────────┼─────────────┤
│emotions │remotions │
├────────────┼─────────────┤
│toweled │troweled │
├────────────┼─────────────┤
│cedent │credent │
├────────────┼─────────────┤
│well-famed │well-farmed │
├────────────┼─────────────┤
│boddle │broddle │
├────────────┼─────────────┤
│shoved │shroved │
├────────────┼─────────────┤
│phatic │phratric │
├────────────┼─────────────┤
│factions │fractions │
└────────────┴─────────────┘
#n
2371
BQN
words ← ((5⊸<≠)¨/⊢) •file.Lines "/usr/share/dict/words"
# has r no r in last 2 chars
r ← ((>'r'⊸∊¨)/⊢) ((>('r'⊸(¬∘∊)¨ ¯2⊸↑¨))/⊢) words
n ← ((¬∘∊/⊣)⟜"rR")¨ r
r ↩ (n ∊ words)/r
n ↩ (n ∊ words)/n
⍉>(10 •rand.Range ≠n)⊸⊏¨ n‿r
┌─
╵ "scogie" "scrogie"
"stammel" "stammrel"
"spatling" "spartling"
"boguing" "broguing"
"lakish" "larkish"
"bangled" "brangled"
"bought" "brought"
"libated" "librated"
"sticks" "stricks"
"desecate" "desecrate"
┘
≠n
2371
Lil
wods:"\n" split "r" drop words:read["/usr/share/dict/words"]
words:"\n" split words
still:select word:words@index wod:value
where (wods in words)&(extract (value like "*r*")&!value like "*er" from words)
from wods
table random[still -10]
+-----------------+----------------+
| word | wod |
+-----------------+----------------+
| "farcy" | "facy" |
| "cyclers" | "cycles" |
| "trailing" | "tailing" |
| "rull" | "ull" |
| "bracken" | "backen" |
| "psychrophobia" | "psychophobia" |
| "tyring" | "tying" |
| "starves" | "staves" |
| "grabblers" | "gabbles" |
| "redear" | "edea" |
+-----------------+----------------+