18
2
Working with old files from DOS, I found an ancient text animation format, that specify how much time each frame must be shown in the screen. It's very simple:
F1W5F2W3
This example above indicates that Frame 1 must be shown for 5 units of time, and frame 2 for 3 units more. Now I want to convert it to:
1, 1, 1, 1, 1, 2, 2, 2
In the converted example below, frame 1 is repeated 5 times, and frame 2 three times.
Rules: The only allowed letters are F and W (and the lowercase counterparts, f and w). Numbers can go up to 255. Total input String with no more than 255 chars.
Other examples:
Input: F10W3F11W3F10W3F12W3
Output: 10, 10, 10, 11, 11, 11, 10, 10, 10, 12, 12, 12
Input: f1w0f2w10
Output: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
Short code wins.
Edited - Accepted formats: Any answer containing the output and ignoring spaces. Ex: 1, 1, 2, 2 or [1,1,2,2] or (1,1,2,2). But NOT 1 1 2 2 or [1; 1; 2; 2] or [1 1 2 2].
7
Welcome to Programming Puzzles & Code Golf! Just so you know, bonuses in code golf are discouraged.
– Dennis – 2016-08-23T03:33:09.4171Ok, thank you for the information. I have removed the bonus. – Chaotic – 2016-08-23T03:39:21.733
12
This might be a duplicate of this run-length decoding challenge.
– xnor – 2016-08-23T03:54:15.3301Not a duplicate, because in the link above the numbers range from 1 to 9 only. This makes a big difference. – Chaotic – 2016-08-23T04:09:34.630
3Do we have to support upper and lower case? Or just one or the other? – James – 2016-08-23T04:59:54.603
2Would it be acceptable to output an extra comma at the end of the output? – James – 2016-08-23T06:13:30.183
Can the output be only comma separated I.e.
10,10,10
instead of10, 10, 10
? – TheLethalCoder – 2016-08-23T11:27:47.573I don't see as a problem having spaces (or not) between commas. But it is not acceptable to output an extra comma at the end of the output (just for fairness with other competitors). – Chaotic – 2016-08-24T14:10:54.747
What output formats are accepted, exactly? [1, 1, 2, 2] as in some answers? [1 1 2 2]? [1; 1; 2; 2]? – Luis Mendo – 2016-08-25T18:31:38.013
@LuisMendo Edit made for this. – Chaotic – 2016-08-25T19:02:59.090
I don't think having multiple-digit numbers is enough of a difference to make this not a duplicate. It's a very minor change for most solutions, especially the regex-based ones. – Mego – 2016-09-01T06:58:32.570