From bf10a659e60a77df908278b48c949f31f01cdb68 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 12 Jan 2021 13:50:26 +0100 Subject: AWK solution for week 95, part 1. --- challenge-095/abigail/awk/ch-1.awk | 28 ++++++++++++++++++++++++++++ challenge-095/abigail/t/ctest.ini | 6 ++++++ 2 files changed, 34 insertions(+) create mode 100644 challenge-095/abigail/awk/ch-1.awk diff --git a/challenge-095/abigail/awk/ch-1.awk b/challenge-095/abigail/awk/ch-1.awk new file mode 100644 index 0000000000..e198996b20 --- /dev/null +++ b/challenge-095/abigail/awk/ch-1.awk @@ -0,0 +1,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 +} diff --git a/challenge-095/abigail/t/ctest.ini b/challenge-095/abigail/t/ctest.ini index 3712da6655..250efe85a4 100644 --- a/challenge-095/abigail/t/ctest.ini +++ b/challenge-095/abigail/t/ctest.ini @@ -15,3 +15,9 @@ skip = No Unicode support [1-5/c] skip = No Unicode support + +[1-4/awk] +skip = No Unicode support + +[1-5/awk] +skip = No Unicode support -- cgit