Created
April 4, 2023 18:05
-
-
Save jailsonsf/bb8fb1db5e22771637b89f3a77fdd45d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def char_counter(text, char) | |
text_splited = text.split(' ').join('') | |
text_splited.each_char.tally[char] | |
end | |
puts 'Qual o texto que quer usar:' | |
text = gets.chomp | |
puts 'Qual caracter quer contar:' | |
char = gets.chomp | |
puts "A letra '#{char}' aparece #{char_counter(text, char)} vezes na frase: '#{text}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment