21
1
Help! My Completely Automated Lights From Darks Separator V3001.01 broke! :(
Guidelines
Task
Write a program that will take an input of an array (or a list in some languages) of any amount of strings that are either the letter L or the letter D (representing lights or darks) and output an array that contains two arrays, one with all the L's, and one with all the D's.
Rules
- It's code golf so the shortest answer in bytes wins
- Input will only ever contain capitals
- There must be the same number of L's in the output as there is in the input, same goes for the D's
- The input may only have one element (or maybe even zero elements)
- If one or both of the output arrays contain no elements, output an empty list (in some languages this may mean you need to output a string)
- Always have the first array be the array of L's
Example output:
["L","D","L","D","D"] -> [["L","L"],["D","D","D"]]
["L","L","L"] -> [["L","L","L"],[]]
["D","D"] -> [[],["D","D"]]
[] -> [[],[]]
3Can we input/output as a string? For example:
"LDLDD" -> "LL DDD"
or something like that? – Comrade SparklePony – 2017-07-11T04:54:20.2533Or output perhaps as a list of the two strings, e.g. `"LDLDD" -> ["LL", "DDD"] – Comrade SparklePony – 2017-07-11T07:27:11.780
Would also like an answer, as my answer depends on this – Skidsdev – 2017-07-11T08:46:43.997
How about mixed output? As in an array containing one string and one array of strings? e.g.,
["L","L",["D","D","D"]]
. – Shaggy – 2017-07-11T08:59:43.993No, the output must be an array/list. @ComradeSparklePony – aimorris – 2017-07-11T09:04:41.160
Is it acceptable to take a string as input e.g.
'LDLDD'
instead of['L', 'D', 'L', 'D', 'D']
? – Erik the Outgolfer – 2017-07-11T09:45:02.123@EriktheOutgolfer No the input must be an array/list. However, I would presume in most languages it would be easy to convert an array of string to a string? – aimorris – 2017-07-11T09:48:15.953
@Amorris Yeah it should probably. – Erik the Outgolfer – 2017-07-11T09:49:47.127
@EriktheOutgolfer After all, a string is an array of characters... – aimorris – 2017-07-11T10:03:28.170
Welp, that's braingolf out then. Can't do nested arrays – Skidsdev – 2017-07-11T10:26:05.657
@Amorris what about 2 separate Arrays (IE
[L, L], [D, D, D]
) as opposed to an array of arrays? – Skidsdev – 2017-07-11T10:26:59.510@Mayube Sure thats fine, not sure how your gonna get that in one output though... – aimorris – 2017-07-11T10:31:54.270