Problem 88. It dseon't mettar waht oedrr the lrettes in a wrod are.
An internet meme from 2003 (read more here) asserted that readers are relatively insensitive to letter order in words, so long as the first and last letters are unchanged.
Given a string of words s, take each word in turn and reverse the order of letters 2 through n-1, where n is the length of the words. Non-alphabetic characters should remain in place.
So if
sIn = 'hello'
then
sOut = 'hlleo'
And if
sIn = 'This is the first time I have used MATLAB.'
then
sOut = 'Tihs is the fsrit tmie I hvae uesd MALTAB.'
Solution Stats
Problem Comments
-
6 Comments
Show
3 older comments
Aaron Greisen
on 2 Oct 2022
Needs more test cases. Some would fail with input sIn = 'what is a chain' because of the 'ha' occurring in the middle of both in 'what' and 'chain'. Also needs test cases with hyphened words.
Akash
on 4 Mar 2024
interesting question
Brian Holden
on 21 Nov 2024
I thought the empty set test was uncalled for. Might as well add in numeric arguments if you're wanting to make a case for checking if your inputs are valid.
Solution Comments
Show commentsGroup

MATLAB JOINT CODY EVENT 2024
- 20 Problems
- 10 Finishers
- Slope intercept application
- findPositiveEvenNumbers
- Hemisphere Volume on Top of a Cylinder
- area
- Return area of square
- Potential energy calculation
- Volume and area of a sphere
- Create the following sequence : 0 1 1 4 9 25 64 169 ...
- Unique - Very Very Large Numbers
- Sum of series
- "mirror" matrix
- Pernicious Anniversary Problem
- Find Logic 20
- Remove element(s) from cell array
- Matlab Basics - Rounding II
- It dseon't mettar waht oedrr the lrettes in a wrod are.
- Are all the three given point in the same line?
- Is the Point in a Triangle?
- Counting Sequence
- Word Counting and Indexing
Problem Recent Solvers1930
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!