72
5
Task
Given a string of English names of digits “collapsed” together, like this:
zeronineoneoneeighttwoseventhreesixfourtwofive
Split the string back into digits:
zero nine one one eight two seven three six four two five
Rules
The input is always a string. It always consists of one or more lowercase English digit names, collapsed together, and nothing else.
- The English digit names are
zero one two three four five six seven eight nine
.
- The English digit names are
The output may be a list of strings, or a new string where the digits are delimited by non-alphabetic, non-empty strings. (Your output may also optionally have such strings at the beginning or end, and the delimiters need not be consistent. So even something like
{{ zero0one$$two );
is a valid (if absurd) answer forzeroonetwo
.)The shortest answer in bytes wins.
Test cases
three -> three
eightsix -> eight six
fivefourseven -> five four seven
ninethreesixthree -> nine three six three
foursixeighttwofive -> four six eight two five
fivethreefivesixthreenineonesevenoneeight -> five three five six three nine one seven one eight
threesevensevensixninenineninefiveeighttwofiveeightsixthreeeight -> three seven seven six nine nine nine five eight two five eight six three eight
zeroonetwothreefourfivesixseveneightnine -> zero one two three four five six seven eight nine
28This is an excellent challenge! The task is extremely easy to understand and verify, but the right approach to use isn't very obvious. And choosing the right approach could make a huge difference in score. +1 :) – James – 2017-11-20T17:27:22.523
1
After thinking this up, I remembered a similar, but more simplistic challenge on anarchy golf: yesno! It sparked some amazing C answers. I hope to see one of those soon :)
– Lynn – 2017-11-20T17:41:43.243I do not think my C answer qualifies as such, but hopefully it's a starting point for others with a more twisted sense of humor than myself. – Michael Dorgan – 2017-11-20T20:29:46.017
I'm pretty sure I've seen this same challenge, but where you're supposed to print the actual number. I'm almost certain it was also posted by, you, Lynn; but I've lost the link, hook me up with it? – Magic Octopus Urn – 2017-11-20T22:21:44.950
That wouldn’t have been mine, sorry. Do you mean the challenge was to turn
– Lynn – 2017-11-20T22:37:08.893one two three
intoone hundred and twenty-three
?Can the result be a List of Match objects? (Which saves stringifying the result) – Brad Gilbert b2gills – 2017-11-20T23:13:14.023
@BradGilbertb2gills What’s the string representation of such a list in your language? – Lynn – 2017-11-20T23:15:51.570
If you turn a List of Matches into a Str, it will space separate the strings.
code('eightsix').Str
⇒'eight six'
– Brad Gilbert b2gills – 2017-11-20T23:55:12.160@BradGilbertb2gills I’d say leave the
.Str
in, then. – Lynn – 2017-11-21T00:55:49.1133@MichaelDorgan (or any other C coders), you may want to have a look at the algorithm I used in my Befunge answer. A straight conversion of that to C got me a 104 byte solution, which I think beats all of the existing C answers. I'm willing to bet that could be improved upon by someone with more C golfing skills. – James Holderness – 2017-11-21T03:06:05.093
My straight conversion is around 120 bytes and doesn't handle the \0 char. You are right though, this will be smaller. – Michael Dorgan – 2017-11-21T19:00:20.677