aboutsummaryrefslogtreecommitdiff
path: root/games/squ.awk
blob: 85b0bf0928d8f3ec73b44cff987c5d25f2edae11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
# Make a reduced Latin square out of each line of input
{
    str = toupper($0)
    len = length(str)
    for (i = 1; i <= len; i++)
        let[i - 1] = substr(str, i, 1)
    for (j in let)
        for (k in let)
            printf (k + 1 < len) ? "%s " : "%s\n", let[(k + j) % len]
}