aboutsummaryrefslogtreecommitdiff
path: root/challenge-095/abigail/awk/ch-1.awk
blob: e198996b20af1fd376478ffee75f376731a1175b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    #
    # Initialize
    #
    is_palindrome = 0
}

/^[0-9]+(\.[0-9]+)?$/ {
    #
    # If it looks like an unsigned number, check whether
    # it's a palindrome.
    #
    is_palindrome = 1
    for (i = 1; i <= length / 2; i ++) {
        s1 = substr($0, i, 1)
        s2 = substr($0, length - i + 1, 1)
        if (s1 != s2) {
            is_palindrome = 0
        }
    }
}

{
    #
    # Print result
    #
    print is_palindrome
}