Bash Palindrome Rearranging
palindrome_rearranging() {
local _s=$1
local -A _val
local _i _c
for ((_i = 0; _i < ${#_s}; _i++)); do
_c=${_s:_i:1}
_val[$_c]=$(( ${_val[$_c]:-0} + 1 ))
done
local _odd=0
for _c in "${!_val[@]}"; do
(( _val[$_c] % 2 != 0 )) && ((_odd++))
done
if (( _odd <= 1 )); then echo true; else echo false; fi
}
This counts character frequency and checks whether the string has the right number of odd counts to form a palindrome.