tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
20
Task/Semordnilap/AWK/semordnilap.awk
Normal file
20
Task/Semordnilap/AWK/semordnilap.awk
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# syntax: GAWK -f SEMORDNILAP.AWK unixdict.txt
|
||||
{ arr[$0]++ }
|
||||
END {
|
||||
PROCINFO["sorted_in"] = "@ind_str_asc"
|
||||
for (word in arr) {
|
||||
rword = ""
|
||||
for (j=length(word); j>0; j--) {
|
||||
rword = rword substr(word,j,1)
|
||||
}
|
||||
if (word == rword) { continue } # palindrome
|
||||
if (rword in arr) {
|
||||
if (word in shown || rword in shown) { continue }
|
||||
shown[word]++
|
||||
shown[rword]++
|
||||
if (n++ < 5) { printf("%s %s\n",word,rword) }
|
||||
}
|
||||
}
|
||||
printf("%d words\n",n)
|
||||
exit(0)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue