class Object
Public Instance Methods
can_it_palindrome(string, case_sensitive = true)
click to toggle source
# File lib/can_palindrome.rb, line 7 def can_it_palindrome(string, case_sensitive = true) is_even = (string.length % 2 == 0) string.upcase! if !case_sensitive if is_even return true if (string.length / 2) == pair_count(string) else return true if ((string.length - 1) / 2) == pair_count(string) end return false end
can_palindrome(string, case_sensitive = true)
click to toggle source
# File lib/can_palindrome.rb, line 20 def can_palindrome(string, case_sensitive = true) can_it_palindrome(string, case_sensitive) end
pair_count(string)
click to toggle source
# File lib/can_palindrome.rb, line 3 def pair_count(string) string.chars.select{ |char| (string.count(char) % 2 == 0) }.uniq.count end