tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
29
Task/Semordnilap/NetRexx/semordnilap.netrexx
Normal file
29
Task/Semordnilap/NetRexx/semordnilap.netrexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
/* REXX ***************************************************************
|
||||
* 07.09.2012 Walter Pachl
|
||||
**********************************************************************/
|
||||
fid = 'unixdict.txt' /* the test dictionary */
|
||||
ifi = File(fid)
|
||||
ifr = BufferedReader(FileReader(ifi))
|
||||
have = '' /* words encountered */
|
||||
pi = 0 /* number of palindromes */
|
||||
loop label j_ forever /* as long there is input */
|
||||
line = ifr.readLine /* read a line (String) */
|
||||
if line = null then leave j_ /* NULL indicates EOF */
|
||||
w = Rexx(line) /* each line contains 1 word */
|
||||
If w > '' Then Do /* not a blank line */
|
||||
r = w.reverse /* reverse it */
|
||||
If have[r] > '' Then Do /* was already encountered */
|
||||
pi = pi + 1 /* increment number of pal's */
|
||||
If pi <= 5 Then /* the first 5 are listed */
|
||||
Say have[r] w
|
||||
End
|
||||
have[w] = w /* remember the word */
|
||||
End
|
||||
end j_
|
||||
ifr.close
|
||||
|
||||
Say pi 'words in' fid 'have a palindrome' /* total number found */
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue