All challenges

Saturday, 10 October 2026

Past

Three rungs, one idea. Solving rung 1 counts. Climb as far as you can.

Putting Words Together

strings + joining with spaces

Rung 1Daily goal5 points

One space between each

Write a function called join_words

Return one string made of every word in the list with a single space between them, so ["cat", "dog"] gives "cat dog". There is no space at the start or the end. An empty list returns an empty string.

Examples

InputOutput
["cat", "dog"]"cat dog"
[]""
["one"]"one"
["a", "b", "c"]"a b c"

There are extra hidden tests, so make it work in general, not just for these.

Rung 2Bonus7 points

Clean them up first

Write a function called tidy_line

The words may have extra spaces around them, and some may be nothing but spaces. Take the spaces off both ends of each word, throw away any word that is left with nothing, then join what remains with single spaces. [" cat ", " ", "dog"] gives "cat dog". If nothing survives, return an empty string.

Examples

InputOutput
[" cat ", " ", "dog"]"cat dog"
[]""
[" "]""
[" one "]"one"

There are extra hidden tests, so make it work in general, not just for these.

Rung 3Bonus10 points

Fit them into lines

Write a function called wrap_words

Put the words into lines that are never longer than limit characters, counting the single spaces between words. Fill each line with as many words as fit before starting the next one, and keep the words in order. No word is ever longer than limit on its own. An empty list returns an empty list.

Examples

InputOutput
["aa", "bb", "cc"], 5["aa bb", "cc"]
[], 5[]
["aa"], 5["aa"]
["a", "b", "c"], 1["a", "b", "c"]

There are extra hidden tests, so make it work in general, not just for these.

Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.