Hey, here's my solution with ruby.
DATA = File.open('input.txt') main_data = DATA.read char_hash = Hash.new { |h, k| h[k] = [] } def reduce_string(string) loop do last_length = string.size ('a'..'z').each do |letter| string.gsub!("#{letter}#{letter.upcase}", '') string.gsub!("#{letter.upcase}#{letter}", '') end break if last_length == string.size end string.size end def remove_letters(string, letter) string = string.dup string.gsub!(letter, '') string.gsub!(letter.upcase, '') end ('a'..'z').each do |letter| char_hash[letter] = reduce_string(remove_letters(main_data, letter)) end puts reduce_string(main_data) puts char_hash.values.min
Nice and clean!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey, here's my solution with ruby.
Nice and clean!