404

[ Avaa Bypassed ]




Upload:

Command:

botdev@52.14.3.26: ~ $
# anagram.awk --- An implementation of the anagram-finding algorithm
#                 from Jon Bentley's "Programming Pearls," 2nd edition.
#                 Addison Wesley, 2000, ISBN 0-201-65788-0.
#                 Column 2, Problem C, section 2.8, pp 18-20.
#
# This program requires gawk 4.0 or newer.
# Required gawk-specific features:
#   - True multidimensional arrays
#   - split() with "" as separator splits out individual characters
#   - asort() and asorti() functions
#
# See http://savannah.gnu.org/projects/gawk.
#
# Arnold Robbins
# arnold@skeeve.com
# Public Domain
# January, 2011

/'s$/   { next }        # Skip possessives
{
    key = word2key($1)  # Build signature
    data[key][$1] = $1  # Store word with signature
}
# word2key --- split word apart into letters, sort, and join back together

function word2key(word,     a, i, n, result)
{
    n = split(word, a, "")
    asort(a)

    for (i = 1; i <= n; i++)
        result = result a[i]

    return result
}
END {
    sort = "sort"
    for (key in data) {
        # Sort words with same key
        nwords = asorti(data[key], words)
        if (nwords == 1)
            continue

        # And print. Minor glitch: trailing space at end of each line
        for (j = 1; j <= nwords; j++)
            printf("%s ", words[j]) | sort
        print "" | sort
    }
    close(sort)
}

Filemanager

Name Type Size Permission Actions
alarm.awk File 2.31 KB 0644
anagram.awk File 1.33 KB 0644
awksed.awk File 515 B 0644
cut.awk File 3.61 KB 0644
dupword.awk File 507 B 0644
egrep.awk File 1.91 KB 0644
extract.awk File 1.74 KB 0644
guide.awk File 165 B 0644
histsort.awk File 283 B 0644
id.awk File 1.22 KB 0644
igawk.sh File 3.11 KB 0644
indirectcall.awk File 952 B 0644
labels.awk File 1014 B 0644
split.awk File 1.17 KB 0644
tee.awk File 770 B 0644
testbits.awk File 729 B 0644
translate.awk File 1.15 KB 0644
uniq.awk File 2.64 KB 0644
wc.awk File 1.45 KB 0644
wordfreq.awk File 347 B 0644