Great to have you back Leitz!
I find it fun (and helps with motivation) to define a specific arbitrary problem and post my solution/s
here at Perl Monks, inviting others to join in and/or give feedback.
For a simple one to get you started, write a function to reverse a string of words.
For example, given an input string of:
" one two three four "
your function should produce:
"four three two one"
That is, the input string reversed word by word, with a single
space between each word and with no leading or trailing space.
You may assume the input string consists only of alphabetic
characters, spaces and tabs.
When you're done, take a look at the many instructive replies at: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell) ...
wow, just remembered this challenge provoked a Perl 6 reply from The Larry himself (aka TimToady)!
Some more examples of this approach:
Conway's classic Game of Life was my favourite, I became a bit obsessed with it - being a meatier problem, it took way more time than the others.
Sadly, John Horton Conway, the inventor of the Game of Life,
died last year of COVID-19.
|