programming-examples/ruby/Algorithms/permutation_palindrome.rb
2019-11-15 12:59:38 +01:00

15 lines
215 B
Ruby

def permutation_palindrome(str)
dict = {}
odds = 0
str.chars.map do |val|
dict[val] = dict[val] ? dict[val] += 1 : 1
end
dict.keys.map do |key|
odds += 1 if dict[key].odd?
end
odds <= 1
end