ûèB☼å°╤
Run and debug it st staxlang.xyz!
Unpacked (8 bytes) and explanation:
m|RFNppz
m For each line of input:
|R Run-length encode: "heeeello" -> [[104,1],[101,4],[108,2],[111,1]]
F For each pair:
N Uncons-left: [104,1] -> push [104]; push 1
ppz Pop and print. Pop and print. Push "".
Implicit print (always an empty string) with a newline
5 bytes, works only on a single line:
∩l↨me
|RmEp] Unpacked
|R Run-length encode: "heeeello" -> [[104,1],[101,4],[108,2],[111,1]]
m Map block over input:
E Explode array: [104,1] -> push 104, push 1
p Pop and print with no newline
] Make a one-element list: 104 -> [104] (which is "h")
Implicit print with newline
Run and debug it at staxlang.xyz!
Perhaps not legal. This program prints each pair on a line of its own. A bit sketchy.
If that output format is illegal, I give you 6 bytes:
╡δôZ→╬
|RFEp]p Unpacked
F For each item in array, execute block:
p Pop and print with no newline
No implicit print in for-each block, so no extra newlines
Run and debug it at staxlang.xyz!
The language's creator recursive points out that uncons-right (N) can shorten this to six bytes unpacked, as it handles the E and the ] on its own. Programs this short, however, often get no shorter when packed, and this is am example. Still six bytes: |RFNpp Edit: Had to update my main answer; this form is what I used.
3
You can (typically) save quite a bit if you ignore all ones, e.g.
– primo – 2012-09-14T09:54:39.130w4orldinstead of1w4o1r1l1d(you'd need to escape numerics, e.g. `f111 -> f3\1´). But then it would be a near-duplicate of this: http://codegolf.stackexchange.com/questions/67741
As it is it's close enough to Run-Length Encoding that I vote to close as dupe. It's not going to provide any new challenge or points of interest.
– Peter Taylor – 2012-09-14T12:15:25.910Bonus points for whoever manages to find a fixpoint. – FUZxxl – 2012-09-15T18:11:03.840
Run-Length Encoding may be the same at its core but the input format and the required output format are very different. – mroman – 2012-09-15T18:16:57.603
4@FUZxxl,
22is a trivial fixpoint. – Peter Taylor – 2012-09-17T18:15:22.2932@PeterTaylor And the only nonempty one. We know it must begin with a digit.
11is impossible.22must end there or be followed by another fixed point not beginning with2.333nnnis an impossible pattern, for you'll never find the same character at consecutive odd indices.4444and up fail for the same reason. – Khuldraeseth na'Barya – 2019-08-05T21:26:12.303DIfferent input and output formats are not enough to render questions distinct. – pppery – 2019-08-08T03:27:30.900
Possible duplicate of Run-Length Encoding
– pppery – 2019-08-08T03:27:56.753@pppery I prefer to close that one as a duplicate of this one, since this one is for text, not just numbers. – mbomb007 – 2019-08-08T14:40:05.420