RB
rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Challenge: Counting And Display Strings
# https://www.sololearn.com/Discuss/1003610/challenge-counting-and-display-strings
#
# Enter some phrase, or left blank to use the default one..
input = gets.chomp
default_text = "may the source be with you!"
phrase = input.empty? ? default_text : input
phrase = phrase.split()
len = phrase.size
1.upto(len) do |num|
puts "Word #{num}: #{phrase[num-1]}"
end
puts "Total words in phrase: #{len}"
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run