Semordnilap: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,501: | Line 2,501: | ||
Semordnilap count: 158 |
Semordnilap count: 158 |
||
</pre> |
</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}}== |
=={{header|Python}}== |