dim norm$(27000), result$(270, 2) print "Start reading unixdict.txt" open "i:\unixdict.txt" for reading as #1 while not(eof(#1)) // read to end of file line input #1 in_str$ // get line = word in_str$ = trim$(in_str$) // we don//t want spaces if len(in_str$) > 1 then // if length > 1 then reverse$ rev$ = reverse$(in_str$) if in_str$ <> rev$ then // if in_str is not a palingdrome count = count + 1 // increase counter norm$(count) = in_str$ // store in the array big$ = big$ + rev$ + " " // create big string with reverse$d words fi fi wend close #1 print " ... Done" print print "Start looking for semordnilap" for i = 1 to count for j = 1 to amount // check to avoid the double if result$(j, 2) = norm$(i) continue next j j = instr(big$, " " + norm$(i) + " ") if j <> 0 then // found one amount = amount + 1 // increase counter result$(amount, 1) = norm$(i) // store normal word result$(amount, 2) = reverse$(norm$(i)) // store reverse$ word fi next i print print "Found", amount, " unique semordnilap pairs" print print "Display 5 semordnilap pairs" print count = 0 for i = 1 to amount if len(result$(i, 1)) >= 5 then count = count + 1 print result$(i, 1), chr$(9), result$(i, 2) if count >= 5 break fi next i end sub reverse$(norm$) local rev$, i, l l = len(norm$) - 1 rev$ = norm$ for i = 0 to l mid$(rev$, l - i, 1) = mid$(norm$, i, 1) next i return rev$ end sub