Introduction

Hello, and welcome! Are you ready to take your string manipulation skills to the next level? Today, we'll explore a task that enhances your understanding of strings and trains your ability to think creatively. The task at hand involves splitting a string into words and then reversing each word as if reflected in a mirror using Scala. Intrigued? Let's dive right in!

Task Statement and Description

Consider a string filled with words. Your task is to write a Scala function that accepts such a string. It should then take each of those words, reverse their character order, and finally stitch them all together to form a new string with reversed words.

Here's what you need to keep in mind:

  • The input string will contain between 1 and 100 words.
  • Each word is a sequence of characters separated by white space.
  • A word is composed of characters ranging from a to z, A to Z, 0 to 9, or even an underscore _.
  • The given string will not start or end with a space, and double spaces will not appear either.
  • After reversing the words, your program should return a single string with the words preserving their original order.

Example

Suppose the input string is "Hello neat scala_123".

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal