29
2
Challenge
Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:
- Input any number of strings
- Order them by ascending length
Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):
5 or 4 3 2 1 1 2 3 4 5
Test Cases
Input:
bow
arrows
sheriffOfNottingham
kingRichard
maidMarian
princeJohn
sherwoodForest
Output:
sheriffOfNottingham
kingRichard
maidMarian
bow
arrows
princeJohn
sherwoodForest
Input:
a
bb
cc
Output (both are valid):
bb
a
cc
cc
a
bb
Input:
one
four
seven
fifteen
Possible output (the only other valid output is its vertical mirror):
seven
one
four
fifteen
Notes
The strings are in camelCase and have no numbers or special characters, only lowercase and uppercase letters.
The input can be anything you like: comma-separated as one string, array, ... Any I/O format is allowed.
- Between strings with the same length, any order is accepted.
I feel like there was a very similar challenge before...but welcome to PPCG! – Giuseppe – 2019-04-03T16:48:43.143
@Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it? – Teleporting Goat – 2019-04-03T16:54:41.057
1
well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
– Giuseppe – 2019-04-03T16:55:50.890@Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG... – Teleporting Goat – 2019-04-03T17:03:23.980
1It's OK, we all start from the beginning :-) – Giuseppe – 2019-04-03T17:06:06.323
1Could you add a test case with an even number of strings? – Sherlock9 – 2019-04-03T17:22:06.423
Are we guaranteed that all strings will be unique? – Shaggy – 2019-04-03T19:55:32.930
@Shaggy No, that's not a necessity – Teleporting Goat – 2019-04-03T19:56:54.357
May we return a list of strings? – Adám – 2019-04-03T20:02:03.417
Will strings have at least one character each? – Adám – 2019-04-03T20:12:07.453
@Adám, "Any I/O format is allowed." – Shaggy – 2019-04-03T21:23:27.990