(Inspired by the Keg utility of this challenge)
Given a non-empty input string, e.g. s c 1= e(a"E")
, split the input into even-odd chunks.
Example (Feel free to suggest more)
I can only think of this test case, fee free to suggest more.
This input string, when mapped to its code points, yields the list [115, 32, 99, 32, 49, 61, 32, 101, 40, 97, 34, 69, 34, 41]
. When applied modulo-2 for every item, this returns [1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]
.
In this list let's find the longest possible chunk that is consistent with even and odd code points:
[1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1]
For the first chunk, this yields [1, 0, 1, 0, 1]
because this is the longest chunk that follows the pattern
Odd Even Odd Even Odd Even ...
or
Even Odd Even Odd Even Odd ...
. Adding another codepoint into [1, 0, 1, 0, 1, 1]
breaks the pattern, therefore it is the longest possible even-odd chunk that starts from the beginning of the string.
Using this method, we should split the input into chunks so that this rule applies. Therefore the input becomes (the ;
here is simply a separator; this can be any separator that is not an empty string, Including the string itself):
s c 1;= e(a"E")
However, returning a list of strings is also permitted.
Rules
This is code-golf so the shortest solution wins. Let it be known that flags don't count towards being in the pattern. They also don't count towards byte count in this challenge.
The input will only be in ASCII, and the mapping will always be in ASCII (as far as I can tell most golflangs use a superset of ASCII).
Answering some of the comments
You may output strings as lists of codepoints.
"Any separator" includes the input string itself.
You may insert other characters like the MATL answer, such as alphanumeric characters.
You may not use integers as input instead of ASCII. Doing that will trivialize the challenge.