Jump to content

Semordnilap: Difference between revisions

no edit summary
No edit summary
Line 2,501:
Semordnilap count: 158
</pre>
 
=={{header|PureBasic}}==
<lang PureBasic>If OpenConsole("")=0 : End 1 : EndIf
If ReadFile(0,"./Data/unixdict.txt")=0 : End 2 : EndIf
NewList dict$()
 
While Eof(0)=0 : AddElement(dict$()) : dict$()=Trim(ReadString(0)) : Wend : CloseFile(0)
 
While FirstElement(dict$())
buf$=dict$() : DeleteElement(dict$())
If buf$="" : Continue : EndIf
xbuf$=ReverseString(buf$)
ForEach dict$()
If xbuf$=dict$()
res$+buf$+" / "+xbuf$+#LF$
Break
EndIf
Next
Wend
 
PrintN("Semordnilap pairs found: "+Str(CountString(res$,#LF$)))
For k=1 To 5
If k=1 : PrintN(~"\nFirst 5 pairs: "+StringField(res$,k,#LF$)) : Continue : EndIf
PrintN(Space(15)+StringField(res$,k,#LF$))
Next
Input()</lang>
{{out}}
<pre>Semordnilap pairs found: 158
 
First 5 pairs: able / elba
abut / tuba
ac / ca
ah / ha
al / la</pre>
 
=={{header|Python}}==
164

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.