Teacup rim text: Difference between revisions
Content added Content deleted
m (Rust - simplified code) |
(Added BaCon version.) |
||
Line 71: | Line 71: | ||
10000 words, 5 circular |
10000 words, 5 circular |
||
</pre> |
</pre> |
||
=={{header|BaCon}}== |
|||
This code requires BaCon 3.8.2 or higher. |
|||
<lang bacon>OPTION COLLAPSE TRUE |
|||
dict$ = LOAD$(DIRNAME$(ME$) & "/unixdict.txt") |
|||
FOR word$ IN dict$ STEP NL$ |
|||
IF LEN(word$) = 3 AND AMOUNT(UNIQ$(EXPLODE$(word$, 1))) = 3 THEN domain$ = APPEND$(domain$, 0, word$) |
|||
NEXT |
|||
FOR w1$ IN domain$ |
|||
w2$ = RIGHT$(w1$, 2) & LEFT$(w1$, 1) |
|||
w3$ = RIGHT$(w2$, 2) & LEFT$(w2$, 1) |
|||
IF TALLY(domain$, w2$) AND TALLY(domain$, w3$) AND NOT(TALLY(result$, w1$)) THEN |
|||
result$ = APPEND$(result$, 0, w1$ & " " & w2$ & " " & w3$, NL$) |
|||
ENDIF |
|||
NEXT |
|||
PRINT result$ |
|||
PRINT "Total words: ", AMOUNT(dict$, NL$), ", and ", AMOUNT(result$, NL$), " are circular."</lang> |
|||
{{out}} |
|||
<pre>apt pta tap |
|||
arc rca car |
|||
ate tea eat |
|||
Total words: 25104, and 3 are circular.</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |