Find words whose first and last three letters are equal: Difference between revisions
Content added Content deleted
ReeceGoding (talk | contribs) m (→{{header|R}}: Syntax highlighting.) |
(Added XPL0 example.) |
||
Line 838: | Line 838: | ||
7: tartar |
7: tartar |
||
8: testes |
8: testes |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
<lang XPL0>string 0; \Use zero-terminated strings |
|||
int I, Ch, Len; |
|||
char Word(100); \(longest word in unixdict.txt is 22 chars) |
|||
def LF=$0A, CR=$0D, EOF=$1A; |
|||
[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3 |
|||
OpenI(3); |
|||
repeat I:= 0; |
|||
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR |
|||
if Ch=LF or Ch=EOF then quit; |
|||
Word(I):= Ch; |
|||
I:= I+1; |
|||
]; |
|||
Word(I):= 0; \terminate string |
|||
Len:= I; |
|||
if Len >= 6 then |
|||
if Word(0) = Word(Len-3) & |
|||
Word(1) = Word(Len-2) & |
|||
Word(2) = Word(Len-1) then |
|||
[Text(0, Word); CrLf(0)]; |
|||
until Ch = EOF; |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
antiperspirant |
|||
calendrical |
|||
einstein |
|||
hotshot |
|||
murmur |
|||
oshkosh |
|||
tartar |
|||
testes |
|||
</pre> |
</pre> |