We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't a duplicate.
A single string separated with your OS new-line (i.e.
or an array with multiple strings.
Output - The Stairs:
Remove all non-alphabetic and non-numeric symbols. So all that's left is
[A-Za-z0-9]. And then 'build a stairs'; basically ordering them on length with the smallest at top and widest at the bottom.
- When two strings are of equal length, we merge them with each other as one big string (the order doesn't matter, so it could be from first to last or last to first, whichever of the two you prefer).
- The rule above can stack when the merged strings are of equal length again (see test case 2).
- The input is STDIN and contains only ASCII characters. And the output is STDOUT.
- The case of the output must be the same as the input.
Each submission must be a full program able to compile and run, so not just a method/function.EDIT: I'm rather new, so perhaps it's indeed better to use the default from now on, even though I prefer a full program myself. Sorry for everyone that has already posted a full program. Feel free to edit, and I'll try to not change the post mid-challenge next time.
- This is code-golf, so the shortest answer in bytes wins. I probably accept the shortest answer in a year from now.
Don't let code-golf answers discourage you from posting golfed non-codegolf languages like C# and alike! Try to come up with the shortest answer for any programming language.
- Feel free to use newer languages than this question.
This is a sample text, that you will have to use to build stairs. The wood may be of excellent quality, or pretty crappy almost falling apart and filled with termites. Bla bla bla - some more text Ok, that will do
Okthatwilldo Thisisasampletext Blablablasomemoretext Thewoodmaybeofexcellentquality thatyouwillhavetousetobuildstairs orprettycrappyalmostfallingapartandfilledwithtermites
A small one that contains equal length strings for the special rule
A Or alternatively: A length length oneforthe theforone smallequal equalsmall stringsspecial specialstrings thatrulecontains containsrulethat
Steps explained of 2:
First order on length:
A one for the that rule small equal length strings special contains
A oneforthe thatrule smallequal length stringsspecial contains
Second order on length:
A length thatrule contains oneforthe smallequal stringsspecial
A length thatrulecontains oneforthe smallequal stringsspecial
Third order on length:
A length oneforthe smallequal stringsspecial thatrulecontains
Test, test. This is a test.
a Or alternatively: a is is TesttestThistest testThistestTest
a bc d! 123
123 Or alternatively: 123 adbc dabc