Find words whose first and last three letters are equal: Difference between revisions
Content added Content deleted
(J) |
|||
Line 863: | Line 863: | ||
7. tartar |
7. tartar |
||
8. testes |
8. testes |
||
</pre> |
|||
=={{header|VBScript}}== |
|||
After building a program checking for the 3 letters in any order, i found people just checked the letters in the same order at star and end. I modified my program so it puts an asterisk after the words in the "standard" answer. |
|||
<lang vb> |
|||
with createobject("ADODB.Stream") |
|||
.charset ="UTF-8" |
|||
.open |
|||
.loadfromfile("unixdict.txt") |
|||
s=.readtext |
|||
end with |
|||
a=split (s,vblf) |
|||
set d= createobject("Scripting.Dictionary") |
|||
for each aa in a |
|||
x=trim(aa) |
|||
l=len(x) |
|||
if l>5 then |
|||
d.removeall |
|||
for i=1 to 3 |
|||
m=mid(x,i,1) |
|||
if not d.exists(m) then d.add m,null |
|||
next |
|||
res=true |
|||
for i=l-2 to l |
|||
m=mid(x,i,1) |
|||
if not d.exists(m) then |
|||
res=false:exit for |
|||
else |
|||
d.remove(m) |
|||
end if |
|||
next |
|||
if res then |
|||
wscript.stdout.write left(x & space(15),15) |
|||
if left(x,3)=right(x,3) then wscript.stdout.write "*" |
|||
wscript.stdout.writeline |
|||
end if |
|||
end if |
|||
next |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
alfalfa |
|||
antiperspirant * |
|||
calendrical * |
|||
cataract |
|||
deadhead |
|||
earthenware |
|||
einstein * |
|||
encumbrance |
|||
greenberg |
|||
hannah |
|||
hotshot * |
|||
marjoram |
|||
murmur * |
|||
oshkosh * |
|||
tartar * |
|||
teammate |
|||
tenement |
|||
testes * |
|||
</pre> |
</pre> |
||