Menu
Coddy logo textTech

Recap - String Weaver

Part of the Logic & Flow section of Coddy's Ruby journey — lesson 5 of 56.

Time to combine what you've learned: trimming, interpolation, iteration, and split/join all in one challenge.

challenge icon

Challenge

Easy

Read one line of input, a sentence. Print three lines:

  1. The number of words (split on whitespace)
  2. The sentence with every word reversed but in the same order. For hello world, this is olleh dlrow.
  3. The sentence joined with hyphens, in lowercase. For Hello World, this is hello-world.

For input Hello Ruby World, the output is:

3
olleH ybuR dlroW
hello-ruby-world

Try it yourself

input = gets.chomp

# TODO: print the three required lines

All lessons in Logic & Flow