Decrypt the extended Wechsler format

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
14
down vote

favorite












This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge.




apgsearch, the distributed soup search program for Conway's Game of Life and the search results database, Catagolue use apgcodes to classify and denote patterns. apgcodes themselves use the extended Wechsler format, an extension of a pattern notation developed by Allan Wechsler in 1992.



The following examples and the images are taken from LifeWiki.




  1. A string of n characters in the set matching the regex [0-9a-v] denotes a strip of five rows, n columns wide. Each character denotes five cells in a vertical column corresponding to the bitstrings [00000, 10000, 01000... 00010, 10010, 01010, 11010... 11111].



    For instance, 27deee6 corresponds to a heavyweight spaceship:



27deee6



$$ beginbmatrix
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & 1 & colorGray0 & 1 & 1 & 1 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & 1 \
colorGray0 & colorGray0 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The character z separates contiguous five-row strips.



    For example, 0ca178b96z69d1d96 corresponds to a 31-bit still life:



enter image description here



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & 1 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 \
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The characters w and x are used to abbreviate 00 and 000, respectively.



    So w33z8kqrqk8zzzx33 corresponds to a trans-queen bee shuttle:





enter image description here



enter image description here



(10 blank rows omitted)



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 \
1 & colorGray0 & 1 & 1 & 1 & colorGray0 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. Finally, the symbols matching the regex y[0-9a-z] correspond to runs of between 4 and 39 consecutive 0s.



    A good example is 31a08zy0123cko, corresponding to a ship on quadpole:





enter image description here



enter image description here



$$ beginbmatrix
1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1
endbmatrix $$



The Challenge



Write a program or a function to parse a string of the extended Wechsler format, defined above, and print (or return) the pattern corresponding to this string.



You may assume that the string is nonempty, and does not start or end with z.



You may use any reasonable output format, e.g., a string, a matrix, a 2d array. You may use any two values to represent 0 and 1, given that you declare them in the answer.



You may omit the trailing zeroes lines in the output, or add extra trailing zeroes lines. You may also add/omit trailing zeroes on each line, as long as all lines have the same length in the output.



You may return the transpose of the array, if that is more convenient.



This is code-golf, so the shortest code wins.



Test cases



153 => [[1, 1, 1], [0, 0, 1], [0, 1, 0], [0, 0, 0], [0, 0, 0]]
27deee6 => [[0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]
0ca178b96z69d1d96 => [[0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]
w33z8kqrqk8zzzx33 => [[0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]
31a08zy0123cko => [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]]
o5995ozes88sezw33 => [[0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]
y3343x6bacy6cab6x343zkk8yy8kk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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]






share|improve this question





















  • Will z ever occur at the very beginning?
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
    – alephalpha
    yesterday






  • 3




    Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
    – Arnauld
    yesterday











  • "You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
    – Jonathan Allan
    20 hours ago






  • 1




    Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
    – Jonathan Allan
    19 hours ago














up vote
14
down vote

favorite












This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge.




apgsearch, the distributed soup search program for Conway's Game of Life and the search results database, Catagolue use apgcodes to classify and denote patterns. apgcodes themselves use the extended Wechsler format, an extension of a pattern notation developed by Allan Wechsler in 1992.



The following examples and the images are taken from LifeWiki.




  1. A string of n characters in the set matching the regex [0-9a-v] denotes a strip of five rows, n columns wide. Each character denotes five cells in a vertical column corresponding to the bitstrings [00000, 10000, 01000... 00010, 10010, 01010, 11010... 11111].



    For instance, 27deee6 corresponds to a heavyweight spaceship:



27deee6



$$ beginbmatrix
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & 1 & colorGray0 & 1 & 1 & 1 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & 1 \
colorGray0 & colorGray0 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The character z separates contiguous five-row strips.



    For example, 0ca178b96z69d1d96 corresponds to a 31-bit still life:



enter image description here



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & 1 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 \
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The characters w and x are used to abbreviate 00 and 000, respectively.



    So w33z8kqrqk8zzzx33 corresponds to a trans-queen bee shuttle:





enter image description here



enter image description here



(10 blank rows omitted)



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 \
1 & colorGray0 & 1 & 1 & 1 & colorGray0 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. Finally, the symbols matching the regex y[0-9a-z] correspond to runs of between 4 and 39 consecutive 0s.



    A good example is 31a08zy0123cko, corresponding to a ship on quadpole:





enter image description here



enter image description here



$$ beginbmatrix
1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1
endbmatrix $$



The Challenge



Write a program or a function to parse a string of the extended Wechsler format, defined above, and print (or return) the pattern corresponding to this string.



You may assume that the string is nonempty, and does not start or end with z.



You may use any reasonable output format, e.g., a string, a matrix, a 2d array. You may use any two values to represent 0 and 1, given that you declare them in the answer.



You may omit the trailing zeroes lines in the output, or add extra trailing zeroes lines. You may also add/omit trailing zeroes on each line, as long as all lines have the same length in the output.



You may return the transpose of the array, if that is more convenient.



This is code-golf, so the shortest code wins.



Test cases



153 => [[1, 1, 1], [0, 0, 1], [0, 1, 0], [0, 0, 0], [0, 0, 0]]
27deee6 => [[0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]
0ca178b96z69d1d96 => [[0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]
w33z8kqrqk8zzzx33 => [[0, 0, 1, 1, 0, 0, 0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    yesterday










  • @Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
    – alephalpha
    yesterday






  • 3




    Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
    – Arnauld
    yesterday











  • "You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
    – Jonathan Allan
    20 hours ago






  • 1




    Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
    – Jonathan Allan
    19 hours ago












up vote
14
down vote

favorite









up vote
14
down vote

favorite











This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge.




apgsearch, the distributed soup search program for Conway's Game of Life and the search results database, Catagolue use apgcodes to classify and denote patterns. apgcodes themselves use the extended Wechsler format, an extension of a pattern notation developed by Allan Wechsler in 1992.



The following examples and the images are taken from LifeWiki.




  1. A string of n characters in the set matching the regex [0-9a-v] denotes a strip of five rows, n columns wide. Each character denotes five cells in a vertical column corresponding to the bitstrings [00000, 10000, 01000... 00010, 10010, 01010, 11010... 11111].



    For instance, 27deee6 corresponds to a heavyweight spaceship:



27deee6



$$ beginbmatrix
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & 1 & colorGray0 & 1 & 1 & 1 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & 1 \
colorGray0 & colorGray0 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The character z separates contiguous five-row strips.



    For example, 0ca178b96z69d1d96 corresponds to a 31-bit still life:



enter image description here



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & 1 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 \
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The characters w and x are used to abbreviate 00 and 000, respectively.



    So w33z8kqrqk8zzzx33 corresponds to a trans-queen bee shuttle:





enter image description here



enter image description here



(10 blank rows omitted)



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 \
1 & colorGray0 & 1 & 1 & 1 & colorGray0 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. Finally, the symbols matching the regex y[0-9a-z] correspond to runs of between 4 and 39 consecutive 0s.



    A good example is 31a08zy0123cko, corresponding to a ship on quadpole:





enter image description here



enter image description here



$$ beginbmatrix
1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1
endbmatrix $$



The Challenge



Write a program or a function to parse a string of the extended Wechsler format, defined above, and print (or return) the pattern corresponding to this string.



You may assume that the string is nonempty, and does not start or end with z.



You may use any reasonable output format, e.g., a string, a matrix, a 2d array. You may use any two values to represent 0 and 1, given that you declare them in the answer.



You may omit the trailing zeroes lines in the output, or add extra trailing zeroes lines. You may also add/omit trailing zeroes on each line, as long as all lines have the same length in the output.



You may return the transpose of the array, if that is more convenient.



This is code-golf, so the shortest code wins.



Test cases



153 => [[1, 1, 1], [0, 0, 1], [0, 1, 0], [0, 0, 0], [0, 0, 0]]
27deee6 => [[0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]
0ca178b96z69d1d96 => [[0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0], [1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]






share|improve this question













This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge.




apgsearch, the distributed soup search program for Conway's Game of Life and the search results database, Catagolue use apgcodes to classify and denote patterns. apgcodes themselves use the extended Wechsler format, an extension of a pattern notation developed by Allan Wechsler in 1992.



The following examples and the images are taken from LifeWiki.




  1. A string of n characters in the set matching the regex [0-9a-v] denotes a strip of five rows, n columns wide. Each character denotes five cells in a vertical column corresponding to the bitstrings [00000, 10000, 01000... 00010, 10010, 01010, 11010... 11111].



    For instance, 27deee6 corresponds to a heavyweight spaceship:



27deee6



$$ beginbmatrix
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & 1 & colorGray0 & 1 & 1 & 1 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & 1 \
colorGray0 & colorGray0 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The character z separates contiguous five-row strips.



    For example, 0ca178b96z69d1d96 corresponds to a 31-bit still life:



enter image description here



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & 1 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 \
colorGray0 & 1 & 1 & colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & 1 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. The characters w and x are used to abbreviate 00 and 000, respectively.



    So w33z8kqrqk8zzzx33 corresponds to a trans-queen bee shuttle:





enter image description here



enter image description here



(10 blank rows omitted)



enter image description here



$$ beginbmatrix
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 \
1 & colorGray0 & 1 & 1 & 1 & colorGray0 & 1 \
colorGray0 & 1 & 1 & 1 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0
endbmatrix $$




  1. Finally, the symbols matching the regex y[0-9a-z] correspond to runs of between 4 and 39 consecutive 0s.



    A good example is 31a08zy0123cko, corresponding to a ship on quadpole:





enter image description here



enter image description here



$$ beginbmatrix
1 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 & colorGray0 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1 & colorGray0 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & colorGray0 & 1 \
colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & colorGray0 & 1 & 1
endbmatrix $$



The Challenge



Write a program or a function to parse a string of the extended Wechsler format, defined above, and print (or return) the pattern corresponding to this string.



You may assume that the string is nonempty, and does not start or end with z.



You may use any reasonable output format, e.g., a string, a matrix, a 2d array. You may use any two values to represent 0 and 1, given that you declare them in the answer.



You may omit the trailing zeroes lines in the output, or add extra trailing zeroes lines. You may also add/omit trailing zeroes on each line, as long as all lines have the same length in the output.



You may return the transpose of the array, if that is more convenient.



This is code-golf, so the shortest code wins.



Test cases



153 => [[1, 1, 1], [0, 0, 1], [0, 1, 0], [0, 0, 0], [0, 0, 0]]
27deee6 => [[0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]
0ca178b96z69d1d96 => [[0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]
w33z8kqrqk8zzzx33 => [[0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]








share|improve this question












share|improve this question




share|improve this question








edited yesterday
























asked yesterday









alephalpha

20.4k32685




20.4k32685











  • Will z ever occur at the very beginning?
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
    – alephalpha
    yesterday






  • 3




    Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
    – Arnauld
    yesterday











  • "You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
    – Jonathan Allan
    20 hours ago






  • 1




    Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
    – Jonathan Allan
    19 hours ago
















  • Will z ever occur at the very beginning?
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
    – alephalpha
    yesterday






  • 3




    Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
    – Arnauld
    yesterday











  • "You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
    – Jonathan Allan
    20 hours ago






  • 1




    Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
    – Jonathan Allan
    19 hours ago















Will z ever occur at the very beginning?
– Mr. Xcoder
yesterday




Will z ever occur at the very beginning?
– Mr. Xcoder
yesterday












@Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
– alephalpha
yesterday




@Mr.Xcoder The LifeWiki page does not say anything about that. But you can assume here that the string does not start or end with z.
– alephalpha
yesterday




3




3




Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
– Arnauld
yesterday





Not really a Game of Life pattern, but just for fun: vv99f60vv99f60uv11320uv19rqz33y133y11322310132231
– Arnauld
yesterday













"You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
– Jonathan Allan
20 hours ago




"You may return the transpose of the array" - if that's OK, what about other symmetries like upside-down etc...?
– Jonathan Allan
20 hours ago




1




1




Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
– Jonathan Allan
19 hours ago




Two of the first three answers fail for some of these: 1yx1, 1yy1, 1yw1 and 1yz1. Maybe they should be tests.
– Jonathan Allan
19 hours ago










6 Answers
6






active

oldest

votes

















up vote
6
down vote













JavaScript (ES8), 197 bytes



Takes input as a string. Returns an array of strings with '#' and spaces. The output may include extra (but consistent) trailing spaces on each line.





s=>[x='x',...s.replace(/w|x|y./g,s=>''.padEnd(s<x?2:s>x?P(s[1],36)+4:3),P=parseInt)].map(c=>[!++w,1,2,3,4].map(i=>c<x?o[y+i-5]+=' #'[P(c,36)>>i&1]:o=[...++y&&o,'']),w=y=o=)&&o.map(r=>r.padEnd(w))


Try it online! (prettified output)



How?



Global variables



  • The character "x" is used several times, so it's worth storing it into the variable x.

  • The function parseInt is used twice, so it's worth storing it into the variable P.


  • y is the row index, initialized to 0.


  • w keeps track of an upper bound of the width which is used to pad the final output.


  • o[ ] is the output array, initially empty.

Pre-processing of repeated zeros



We first replace all patterns "w", "x" and "yX" in the input string with the appropriate number of spaces. These spaces will later be interpreted as "0".



s.replace(
/w|x|y./g,
s => ''.padEnd(
// w --> 2
s < x ? 2 :
// yX --> value of X + 4
s > x ? P(s[1], 36) + 4 :
// x --> 3
3
)
)


Decoding



We split the resulting string, prepend an initial "x" and iterate 5 times (with i = 0 to 4) on each character c:




  • If c is lower than "x", we append the corresponding pattern to the next 5 rows.



    o[y + i - 5] += ' #'[P(c, 36) >> i & 1]



  • If c is greater than or equal to "x", we allocate 5 new empty strings in o[ ] and add 5 to y. This is triggered by the initial "x" that was added at the beginning of the string, or by any "z" in the original content.



    o = [...++y && o, '']


Padding



Finally, we pad each string in o[ ] with spaces so that they all have w characters.



o.map(r => r.padEnd(w))





share|improve this answer






























    up vote
    5
    down vote














    05AB1E, 148 132 bytes



    I'm a highschool student and this was my first time for both golfing and using 05AB1E, so comments are appreciated!



    "yy"¾38×:'yð:žhA«DUsð«#εN>≠iDнXsk4+s¦s0s×ì}}'w¾2×:'x¾3×:J'zð:ð«#DéθgUεDgXs-0s׫}vNUyvN₄+₄*X+VDykD32‹ibDg5s-0s×ìRX0Qi¶ì}Yð«ìˆ]¯ε#θJ


    Try it online!



    Try it online!



    Outputs the transposed matrix as multiple output lines of 1s and 0s. If you want pretty-printed output, add J'1'█:'0'.: at the end.



    Will add extra zeros.



    Explanation



    (I'm calling "rows" and "columns" opposite of what you might expect because it generates the transposed matrix)



    The basic algorithm is:



    1. Replace "yy" with 38 0s

    2. Split on "y" and and expand the 0-runs.

    3. Replace "w" and "x"

    4. Figure out the longest column (that is, the longest string between z's) and pad all the other columns so they are that length. (This is necessary because of how the algorithm below works)

    5. Split on z

    6. At this point, the input string is an array of columns where each column is a string of [0-9a-v], where each column is the same length.

    7. The algorithm to get it into the output format is to

      1. Convert the characters to numbers by using indexOf in a lookup string

      2. Convert the characters to binary and then pad to length 5

      3. If it is the first column, add a linebreak before the binary number

      4. Add a prefix to the beginning of the binary string that stores the row and then the column of the character.

      5. Push the binary string with prefix to 05AB1E's "global array" register/variable


    8. Sort the global array. The prefix string, which determines the sort order, will make sure everything ends up in the right order and the linebreaks are in the right places.

    9. Remove the prefix string from each element of the global array

    10. Join the array with "" and print it.

    There are some other minor details you can see below in the expanded code. Everything after the tabs at the end of a line is a comment and can be ignored. (This comment scheme is not part of 05AB1E, by the way. I did it this way because it looked nice.) Lines that have comments starting with "@" are for debugging purposes and can be omitted without changing the final output.



    "yy"¾38×: Replace "yy" with 38 0's. (y is the 34th character in the index, so need to add 34+4 = 38). ¾ is initialized to zero, which saves one byte from typing '038
    'yð: Replace "y" with " "
    "Replaced input Stage1 = "?D, @DEBUG

    žhA« Pushes [0-9a-z]
    DU Set X to [0-9a-z] and leave [0-9a-z] on the stack.
    s Swap top two elements. Now the stack is [0-9a-z],input

    ð« Append a space so the below splitter works even if there are no other spaces.
    # Split input on " ", which "y" has been replaced with
    ε Map. This map replaces the y runs
    "Element = "?D, @DEBUG
    "N = "?N, @DEBUG
    N>≠i If N != 0
    "Replacing!", @DEBUG
    Dн Get the first letter
    X Push X
    s Swap
    k X (which is [0-9a-z]) .indexOf(firstLetter)
    "indexOf run token = "?D, @DEBUG
    4+ Add 4 to the index, now becoming the number of zeros to add
    s Swap. Now top is the string between runs
    ¦ Remove the first character
    s Swap again. Now the top is the number of zeros to add.
    0s×ì Add that many zeros to the start of the element.
    "Element Replaced = "?D, @DEBUG
    }
    }
    'w¾2×: Need to do this replacement after the y replacement so stuff like yw gets parsed properly. Again, ¾ is zero.
    'x¾3×:
    J Join with ""
    "Replaced input Stage2 = "?D, @DEBUG
    'zð: Replace "z" with " "
    ð« Append a space so the below splitter works even if there are no other spaces.
    # Split on space. (Can't do split on z because it splits on z+)
    DéθgU Get max length and store it in X
    "Max length = "?X, @DEBUG
    ε Map
    DgXs- max column length - this column length
    "Zeros to add = "?D, @DEBUG
    0s׫ Add 0s to the end of the column so it is the same length as the longest one.
    }
    "Replaced input Stage3 = "?D, @DEBUG
    "0 Stack top = "?D, @SDEBUG
    "0 Stack top-1 = "?sD,s @SDEBUG
    v pop and loop over top element, which is array of column code
    NU Store the column number in X
    yv Loop over each character in the column
    N₄+₄*X+V Set Y to (rowNumber+1000)*1000+X, where X is the column number. This result is used for sorting.
    "1 Stack top = "?D, @SDEBUG
    "1 Stack top = "?D, @SDEBUG
    D Duplicate top element (which is now [0-9a-z])
    y Push y (special loop variable)
    "Character = "?D, @DEBUG
    k Push indexOf y in [0-9a-z]
    "Index = "?D, @DEBUG
    "2.1 Stack top = "?D, @SDEBUG
    "2.1 Stack top-1 = "?sD,s @SDEBUG
    D Duplicate index.
    32‹i index < 32. This uses up one copy of index
    b Push the index in binary. This uses the second copy of index.
    Dg Get the length of the binary number
    5s- 5 - length
    0s×ì Add 5-length 0s to the start of the binary number
    "Binary = "?D, @SDEBUG
    R Reverse the binary string. This gives the proper transposed output.
    X0Qi If X (which is set to the column number) == 0
    ¶ì Stick a linebreak at the beginning of the binary string
    }
    Y Push Y (the sort prefix).
    ð Push a space character
    «ì This gives "<row prefix> <binary representation of row>"
    "2.5 Stack top = "?D, @SDEBUG
    "2.5 Stack top-1 = "?sD,s @SDEBUG
    "Pushing '"?D?"'", @DEBUG
    ˆ Push "<row prefix>|<binary representation of row>" to global array
    "2.6 Stack top = "?D, @SDEBUG
    "2.6 Stack top-1 = "?sD,s @SDEBUG
    ] Close all blocks
    ¯ Push global array to stack and sort it.
    "Sorted Data = "?D, @DEBUG
    ε Map. This block removes the row numbers
    # Split on spaces
    θ Get the last element

    J Join with ""
    '1'█:'0'.: @DEBUG pretty print





    share|improve this answer



















    • 1




      Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
      – Jonathan Frech
      7 hours ago











    • One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
      – Jonathan Frech
      7 hours ago










    • I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
      – kerwizzy
      6 hours ago










    • Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
      – Jonathan Allan
      3 hours ago










    • Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
      – Kevin Cruijssen
      2 hours ago

















    up vote
    3
    down vote














    APL (Dyalog Unicode), 87 80 bytes



    thangs to H.PWiz for saving 7 bytes



    a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞


    Try it online!



    NB: Takes the input as an upper case string.



    With pretty printed output



    Explanation



    a←⎕D,⎕A a is the string '0123...89ABCD...XYZ'
    ('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match) replaces X W and Yx with the corresponding number of '0's
    'Z'(≠⊆⊢) splits the string at each 'Z'
    ⊖(5/2)⊤a⍳⍵¨ decodes each substring (explained below)
    ,↓↑ reshapes and pads the result, returning a nested boolean array



    ⊖(5/2)⊤a⍳⍵¨
    ¨ ⍝ apply to each substring
    a⍳⍵ ⍝ return indecies of each charactor in a (i.e. '0'=>0, '9'=>9, 'B'=>11
    (5/2)⊤ ⍝ turn each of these into a 5-bit binary column
    ⊖ ⍝ reverse each column





    share|improve this answer























    • Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
      – H.PWiz
      12 hours ago










    • Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
      – jslip
      12 hours ago

















    up vote
    2
    down vote














    Perl 6, 156 142 bytes



    14 bytes saved thanks to Jo King. (Also fixed a little bug with parsing the y and added a prettifier.)



    Fixed the buggy parsing of y[wxy].





    s:g/y(.)/0000 x:36(~$0)/;s:g/x/w0/;s:g/w/00/;s/$/z/;map 
    .flatmap::32($_).fmt("%05b").flip.comb,[Z] .split("z").map: (*~0 x.chars).comb


    Try it online!



    The line break is there just to make the text fit on the screen. It is not a part of the program.



    How does it work



    It is an anonymous function that takes a mutable string. (This makes using the function a little bit peculiar, because you can give it only variables, not literals.) After some work, it returns a list of lists containing 0's and 1's, with the same meaning as in the original post.



    The input string comes in in the variable $_. We start by using a series of substitution statements on it in order to get rid of all of those shorthands for various numbers of zeroes. First, we need to sort out the y, because in the case of yx or yw, the w (or x) does not constitute a shorthand by itself. We search for y(.) (y and one character, which it remembers) and replace it by 000"0"x:36(~$0): the three zeroes are copied verbatim, then we convert the next character from base 36 to base 10 (:36(~$0)) and add that many more zeroes. Then, we replace the w's using s:g/w/00/, and the x's using s:g/x/000/. Finally, with s/$/z/, we add a z onto the end, adding a whole lot of empty lines to the bottom. (We'll see the reason later.)



    The rest is just a big map statement. We're mapping over .split("z").map: (*~0 x.chars).comb}), which is the input string (without zero shorthands), splitted into lines at z, with each line being first padded with 0 x.chars (tons of zeroes, namely as many as is the total length of the input string) on the right and then broken down into a list of individual characters (.comb). Finally, we transpose it with [Z] (reduce with zip). Zipping ends as soon as the shortest list is depleted, which results in all lines having the same length. (The number of useless trailing zeroes on the right is equal to the length of the shortest line. Also, this transposition trick fails for a "matrix" with only one row. That's why we forcibly added another row at the end before.)



    Now, we just map over the rows (columns of the original matrix) and replace each character encountered with the corresponding 5 bits. That is done using :32($_) (base 32 to base 10) .fmt("%05b") (format as a bitstring of width 5, padded with zeroes) .flip (reverse the string, because the LSB is in the top row, not the bottom) .comb (break the string into a list of characters). We have used .flatmap, which flattens the resulting list (otherwise we would get a list of lists in each column). The transpose of the result is then implicitly returned.



    (I feel a little bit bad because of abusing the possibility of trailing zeroes so hard. But it reduced the bytecount quite considerably :—).)






    share|improve this answer























    • 142 bytes
      – Jo King
      yesterday










    • @JoKing — Oh yes, thank you very much!
      – Ramillies
      yesterday










    • Fails for 1yx1 and 1yw1
      – Jonathan Allan
      19 hours ago










    • @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
      – Ramillies
      19 hours ago











    • You can replace the 000 in the y substitution with x
      – Jo King
      9 hours ago

















    up vote
    2
    down vote














    Jelly, 66 bytes



    Yowza!



    ØBiⱮ+
    Œuœṣ⁾YYj38Żṣ”YµḢç3;)Fṣ”Wj2ṣ”Xj3”0ẋ$¹OƑ?€Fṣ”Zµȯ”0ç31BḊ€UZ)Ẏz0


    A monadic link which yields a transposed version as a list of lists (add Z to the end to transpose back).



    Try it online! Or see the test-suite (with pretty printed output).






    share|improve this answer






























      up vote
      0
      down vote














      Python 2, 249 bytes





      def f(s,Z='0'):
      while 'y'in s:i=s.find('y');s=s[:i]+4*Z+Z*int(s[i+1],36)+s[i+2:]
      t=s.replace('w',2*Z).replace('x',3*Z).split('z')
      return map(''.join,zip(*[[(Z*5+bin(int(c,32))[2:])[-5:][::-1]for c in r]+[Z*5]*(max(map(len,t))-len(r))for r in t]))


      Try it online!






      share|improve this answer





















      • There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
        – Jonathan Frech
        7 hours ago










      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "200"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f169976%2fdecrypt-the-extended-wechsler-format%23new-answer', 'question_page');

      );

      Post as a guest






























      6 Answers
      6






      active

      oldest

      votes








      6 Answers
      6






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      6
      down vote













      JavaScript (ES8), 197 bytes



      Takes input as a string. Returns an array of strings with '#' and spaces. The output may include extra (but consistent) trailing spaces on each line.





      s=>[x='x',...s.replace(/w|x|y./g,s=>''.padEnd(s<x?2:s>x?P(s[1],36)+4:3),P=parseInt)].map(c=>[!++w,1,2,3,4].map(i=>c<x?o[y+i-5]+=' #'[P(c,36)>>i&1]:o=[...++y&&o,'']),w=y=o=)&&o.map(r=>r.padEnd(w))


      Try it online! (prettified output)



      How?



      Global variables



      • The character "x" is used several times, so it's worth storing it into the variable x.

      • The function parseInt is used twice, so it's worth storing it into the variable P.


      • y is the row index, initialized to 0.


      • w keeps track of an upper bound of the width which is used to pad the final output.


      • o[ ] is the output array, initially empty.

      Pre-processing of repeated zeros



      We first replace all patterns "w", "x" and "yX" in the input string with the appropriate number of spaces. These spaces will later be interpreted as "0".



      s.replace(
      /w|x|y./g,
      s => ''.padEnd(
      // w --> 2
      s < x ? 2 :
      // yX --> value of X + 4
      s > x ? P(s[1], 36) + 4 :
      // x --> 3
      3
      )
      )


      Decoding



      We split the resulting string, prepend an initial "x" and iterate 5 times (with i = 0 to 4) on each character c:




      • If c is lower than "x", we append the corresponding pattern to the next 5 rows.



        o[y + i - 5] += ' #'[P(c, 36) >> i & 1]



      • If c is greater than or equal to "x", we allocate 5 new empty strings in o[ ] and add 5 to y. This is triggered by the initial "x" that was added at the beginning of the string, or by any "z" in the original content.



        o = [...++y && o, '']


      Padding



      Finally, we pad each string in o[ ] with spaces so that they all have w characters.



      o.map(r => r.padEnd(w))





      share|improve this answer



























        up vote
        6
        down vote













        JavaScript (ES8), 197 bytes



        Takes input as a string. Returns an array of strings with '#' and spaces. The output may include extra (but consistent) trailing spaces on each line.





        s=>[x='x',...s.replace(/w|x|y./g,s=>''.padEnd(s<x?2:s>x?P(s[1],36)+4:3),P=parseInt)].map(c=>[!++w,1,2,3,4].map(i=>c<x?o[y+i-5]+=' #'[P(c,36)>>i&1]:o=[...++y&&o,'']),w=y=o=)&&o.map(r=>r.padEnd(w))


        Try it online! (prettified output)



        How?



        Global variables



        • The character "x" is used several times, so it's worth storing it into the variable x.

        • The function parseInt is used twice, so it's worth storing it into the variable P.


        • y is the row index, initialized to 0.


        • w keeps track of an upper bound of the width which is used to pad the final output.


        • o[ ] is the output array, initially empty.

        Pre-processing of repeated zeros



        We first replace all patterns "w", "x" and "yX" in the input string with the appropriate number of spaces. These spaces will later be interpreted as "0".



        s.replace(
        /w|x|y./g,
        s => ''.padEnd(
        // w --> 2
        s < x ? 2 :
        // yX --> value of X + 4
        s > x ? P(s[1], 36) + 4 :
        // x --> 3
        3
        )
        )


        Decoding



        We split the resulting string, prepend an initial "x" and iterate 5 times (with i = 0 to 4) on each character c:




        • If c is lower than "x", we append the corresponding pattern to the next 5 rows.



          o[y + i - 5] += ' #'[P(c, 36) >> i & 1]



        • If c is greater than or equal to "x", we allocate 5 new empty strings in o[ ] and add 5 to y. This is triggered by the initial "x" that was added at the beginning of the string, or by any "z" in the original content.



          o = [...++y && o, '']


        Padding



        Finally, we pad each string in o[ ] with spaces so that they all have w characters.



        o.map(r => r.padEnd(w))





        share|improve this answer

























          up vote
          6
          down vote










          up vote
          6
          down vote









          JavaScript (ES8), 197 bytes



          Takes input as a string. Returns an array of strings with '#' and spaces. The output may include extra (but consistent) trailing spaces on each line.





          s=>[x='x',...s.replace(/w|x|y./g,s=>''.padEnd(s<x?2:s>x?P(s[1],36)+4:3),P=parseInt)].map(c=>[!++w,1,2,3,4].map(i=>c<x?o[y+i-5]+=' #'[P(c,36)>>i&1]:o=[...++y&&o,'']),w=y=o=)&&o.map(r=>r.padEnd(w))


          Try it online! (prettified output)



          How?



          Global variables



          • The character "x" is used several times, so it's worth storing it into the variable x.

          • The function parseInt is used twice, so it's worth storing it into the variable P.


          • y is the row index, initialized to 0.


          • w keeps track of an upper bound of the width which is used to pad the final output.


          • o[ ] is the output array, initially empty.

          Pre-processing of repeated zeros



          We first replace all patterns "w", "x" and "yX" in the input string with the appropriate number of spaces. These spaces will later be interpreted as "0".



          s.replace(
          /w|x|y./g,
          s => ''.padEnd(
          // w --> 2
          s < x ? 2 :
          // yX --> value of X + 4
          s > x ? P(s[1], 36) + 4 :
          // x --> 3
          3
          )
          )


          Decoding



          We split the resulting string, prepend an initial "x" and iterate 5 times (with i = 0 to 4) on each character c:




          • If c is lower than "x", we append the corresponding pattern to the next 5 rows.



            o[y + i - 5] += ' #'[P(c, 36) >> i & 1]



          • If c is greater than or equal to "x", we allocate 5 new empty strings in o[ ] and add 5 to y. This is triggered by the initial "x" that was added at the beginning of the string, or by any "z" in the original content.



            o = [...++y && o, '']


          Padding



          Finally, we pad each string in o[ ] with spaces so that they all have w characters.



          o.map(r => r.padEnd(w))





          share|improve this answer















          JavaScript (ES8), 197 bytes



          Takes input as a string. Returns an array of strings with '#' and spaces. The output may include extra (but consistent) trailing spaces on each line.





          s=>[x='x',...s.replace(/w|x|y./g,s=>''.padEnd(s<x?2:s>x?P(s[1],36)+4:3),P=parseInt)].map(c=>[!++w,1,2,3,4].map(i=>c<x?o[y+i-5]+=' #'[P(c,36)>>i&1]:o=[...++y&&o,'']),w=y=o=)&&o.map(r=>r.padEnd(w))


          Try it online! (prettified output)



          How?



          Global variables



          • The character "x" is used several times, so it's worth storing it into the variable x.

          • The function parseInt is used twice, so it's worth storing it into the variable P.


          • y is the row index, initialized to 0.


          • w keeps track of an upper bound of the width which is used to pad the final output.


          • o[ ] is the output array, initially empty.

          Pre-processing of repeated zeros



          We first replace all patterns "w", "x" and "yX" in the input string with the appropriate number of spaces. These spaces will later be interpreted as "0".



          s.replace(
          /w|x|y./g,
          s => ''.padEnd(
          // w --> 2
          s < x ? 2 :
          // yX --> value of X + 4
          s > x ? P(s[1], 36) + 4 :
          // x --> 3
          3
          )
          )


          Decoding



          We split the resulting string, prepend an initial "x" and iterate 5 times (with i = 0 to 4) on each character c:




          • If c is lower than "x", we append the corresponding pattern to the next 5 rows.



            o[y + i - 5] += ' #'[P(c, 36) >> i & 1]



          • If c is greater than or equal to "x", we allocate 5 new empty strings in o[ ] and add 5 to y. This is triggered by the initial "x" that was added at the beginning of the string, or by any "z" in the original content.



            o = [...++y && o, '']


          Padding



          Finally, we pad each string in o[ ] with spaces so that they all have w characters.



          o.map(r => r.padEnd(w))






          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited 18 hours ago


























          answered yesterday









          Arnauld

          60k472252




          60k472252




















              up vote
              5
              down vote














              05AB1E, 148 132 bytes



              I'm a highschool student and this was my first time for both golfing and using 05AB1E, so comments are appreciated!



              "yy"¾38×:'yð:žhA«DUsð«#εN>≠iDнXsk4+s¦s0s×ì}}'w¾2×:'x¾3×:J'zð:ð«#DéθgUεDgXs-0s׫}vNUyvN₄+₄*X+VDykD32‹ibDg5s-0s×ìRX0Qi¶ì}Yð«ìˆ]¯ε#θJ


              Try it online!



              Try it online!



              Outputs the transposed matrix as multiple output lines of 1s and 0s. If you want pretty-printed output, add J'1'█:'0'.: at the end.



              Will add extra zeros.



              Explanation



              (I'm calling "rows" and "columns" opposite of what you might expect because it generates the transposed matrix)



              The basic algorithm is:



              1. Replace "yy" with 38 0s

              2. Split on "y" and and expand the 0-runs.

              3. Replace "w" and "x"

              4. Figure out the longest column (that is, the longest string between z's) and pad all the other columns so they are that length. (This is necessary because of how the algorithm below works)

              5. Split on z

              6. At this point, the input string is an array of columns where each column is a string of [0-9a-v], where each column is the same length.

              7. The algorithm to get it into the output format is to

                1. Convert the characters to numbers by using indexOf in a lookup string

                2. Convert the characters to binary and then pad to length 5

                3. If it is the first column, add a linebreak before the binary number

                4. Add a prefix to the beginning of the binary string that stores the row and then the column of the character.

                5. Push the binary string with prefix to 05AB1E's "global array" register/variable


              8. Sort the global array. The prefix string, which determines the sort order, will make sure everything ends up in the right order and the linebreaks are in the right places.

              9. Remove the prefix string from each element of the global array

              10. Join the array with "" and print it.

              There are some other minor details you can see below in the expanded code. Everything after the tabs at the end of a line is a comment and can be ignored. (This comment scheme is not part of 05AB1E, by the way. I did it this way because it looked nice.) Lines that have comments starting with "@" are for debugging purposes and can be omitted without changing the final output.



              "yy"¾38×: Replace "yy" with 38 0's. (y is the 34th character in the index, so need to add 34+4 = 38). ¾ is initialized to zero, which saves one byte from typing '038
              'yð: Replace "y" with " "
              "Replaced input Stage1 = "?D, @DEBUG

              žhA« Pushes [0-9a-z]
              DU Set X to [0-9a-z] and leave [0-9a-z] on the stack.
              s Swap top two elements. Now the stack is [0-9a-z],input

              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split input on " ", which "y" has been replaced with
              ε Map. This map replaces the y runs
              "Element = "?D, @DEBUG
              "N = "?N, @DEBUG
              N>≠i If N != 0
              "Replacing!", @DEBUG
              Dн Get the first letter
              X Push X
              s Swap
              k X (which is [0-9a-z]) .indexOf(firstLetter)
              "indexOf run token = "?D, @DEBUG
              4+ Add 4 to the index, now becoming the number of zeros to add
              s Swap. Now top is the string between runs
              ¦ Remove the first character
              s Swap again. Now the top is the number of zeros to add.
              0s×ì Add that many zeros to the start of the element.
              "Element Replaced = "?D, @DEBUG
              }
              }
              'w¾2×: Need to do this replacement after the y replacement so stuff like yw gets parsed properly. Again, ¾ is zero.
              'x¾3×:
              J Join with ""
              "Replaced input Stage2 = "?D, @DEBUG
              'zð: Replace "z" with " "
              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split on space. (Can't do split on z because it splits on z+)
              DéθgU Get max length and store it in X
              "Max length = "?X, @DEBUG
              ε Map
              DgXs- max column length - this column length
              "Zeros to add = "?D, @DEBUG
              0s׫ Add 0s to the end of the column so it is the same length as the longest one.
              }
              "Replaced input Stage3 = "?D, @DEBUG
              "0 Stack top = "?D, @SDEBUG
              "0 Stack top-1 = "?sD,s @SDEBUG
              v pop and loop over top element, which is array of column code
              NU Store the column number in X
              yv Loop over each character in the column
              N₄+₄*X+V Set Y to (rowNumber+1000)*1000+X, where X is the column number. This result is used for sorting.
              "1 Stack top = "?D, @SDEBUG
              "1 Stack top = "?D, @SDEBUG
              D Duplicate top element (which is now [0-9a-z])
              y Push y (special loop variable)
              "Character = "?D, @DEBUG
              k Push indexOf y in [0-9a-z]
              "Index = "?D, @DEBUG
              "2.1 Stack top = "?D, @SDEBUG
              "2.1 Stack top-1 = "?sD,s @SDEBUG
              D Duplicate index.
              32‹i index < 32. This uses up one copy of index
              b Push the index in binary. This uses the second copy of index.
              Dg Get the length of the binary number
              5s- 5 - length
              0s×ì Add 5-length 0s to the start of the binary number
              "Binary = "?D, @SDEBUG
              R Reverse the binary string. This gives the proper transposed output.
              X0Qi If X (which is set to the column number) == 0
              ¶ì Stick a linebreak at the beginning of the binary string
              }
              Y Push Y (the sort prefix).
              ð Push a space character
              «ì This gives "<row prefix> <binary representation of row>"
              "2.5 Stack top = "?D, @SDEBUG
              "2.5 Stack top-1 = "?sD,s @SDEBUG
              "Pushing '"?D?"'", @DEBUG
              ˆ Push "<row prefix>|<binary representation of row>" to global array
              "2.6 Stack top = "?D, @SDEBUG
              "2.6 Stack top-1 = "?sD,s @SDEBUG
              ] Close all blocks
              ¯ Push global array to stack and sort it.
              "Sorted Data = "?D, @DEBUG
              ε Map. This block removes the row numbers
              # Split on spaces
              θ Get the last element

              J Join with ""
              '1'█:'0'.: @DEBUG pretty print





              share|improve this answer



















              • 1




                Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
                – Jonathan Frech
                7 hours ago











              • One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
                – Jonathan Frech
                7 hours ago










              • I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
                – kerwizzy
                6 hours ago










              • Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
                – Jonathan Allan
                3 hours ago










              • Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
                – Kevin Cruijssen
                2 hours ago














              up vote
              5
              down vote














              05AB1E, 148 132 bytes



              I'm a highschool student and this was my first time for both golfing and using 05AB1E, so comments are appreciated!



              "yy"¾38×:'yð:žhA«DUsð«#εN>≠iDнXsk4+s¦s0s×ì}}'w¾2×:'x¾3×:J'zð:ð«#DéθgUεDgXs-0s׫}vNUyvN₄+₄*X+VDykD32‹ibDg5s-0s×ìRX0Qi¶ì}Yð«ìˆ]¯ε#θJ


              Try it online!



              Try it online!



              Outputs the transposed matrix as multiple output lines of 1s and 0s. If you want pretty-printed output, add J'1'█:'0'.: at the end.



              Will add extra zeros.



              Explanation



              (I'm calling "rows" and "columns" opposite of what you might expect because it generates the transposed matrix)



              The basic algorithm is:



              1. Replace "yy" with 38 0s

              2. Split on "y" and and expand the 0-runs.

              3. Replace "w" and "x"

              4. Figure out the longest column (that is, the longest string between z's) and pad all the other columns so they are that length. (This is necessary because of how the algorithm below works)

              5. Split on z

              6. At this point, the input string is an array of columns where each column is a string of [0-9a-v], where each column is the same length.

              7. The algorithm to get it into the output format is to

                1. Convert the characters to numbers by using indexOf in a lookup string

                2. Convert the characters to binary and then pad to length 5

                3. If it is the first column, add a linebreak before the binary number

                4. Add a prefix to the beginning of the binary string that stores the row and then the column of the character.

                5. Push the binary string with prefix to 05AB1E's "global array" register/variable


              8. Sort the global array. The prefix string, which determines the sort order, will make sure everything ends up in the right order and the linebreaks are in the right places.

              9. Remove the prefix string from each element of the global array

              10. Join the array with "" and print it.

              There are some other minor details you can see below in the expanded code. Everything after the tabs at the end of a line is a comment and can be ignored. (This comment scheme is not part of 05AB1E, by the way. I did it this way because it looked nice.) Lines that have comments starting with "@" are for debugging purposes and can be omitted without changing the final output.



              "yy"¾38×: Replace "yy" with 38 0's. (y is the 34th character in the index, so need to add 34+4 = 38). ¾ is initialized to zero, which saves one byte from typing '038
              'yð: Replace "y" with " "
              "Replaced input Stage1 = "?D, @DEBUG

              žhA« Pushes [0-9a-z]
              DU Set X to [0-9a-z] and leave [0-9a-z] on the stack.
              s Swap top two elements. Now the stack is [0-9a-z],input

              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split input on " ", which "y" has been replaced with
              ε Map. This map replaces the y runs
              "Element = "?D, @DEBUG
              "N = "?N, @DEBUG
              N>≠i If N != 0
              "Replacing!", @DEBUG
              Dн Get the first letter
              X Push X
              s Swap
              k X (which is [0-9a-z]) .indexOf(firstLetter)
              "indexOf run token = "?D, @DEBUG
              4+ Add 4 to the index, now becoming the number of zeros to add
              s Swap. Now top is the string between runs
              ¦ Remove the first character
              s Swap again. Now the top is the number of zeros to add.
              0s×ì Add that many zeros to the start of the element.
              "Element Replaced = "?D, @DEBUG
              }
              }
              'w¾2×: Need to do this replacement after the y replacement so stuff like yw gets parsed properly. Again, ¾ is zero.
              'x¾3×:
              J Join with ""
              "Replaced input Stage2 = "?D, @DEBUG
              'zð: Replace "z" with " "
              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split on space. (Can't do split on z because it splits on z+)
              DéθgU Get max length and store it in X
              "Max length = "?X, @DEBUG
              ε Map
              DgXs- max column length - this column length
              "Zeros to add = "?D, @DEBUG
              0s׫ Add 0s to the end of the column so it is the same length as the longest one.
              }
              "Replaced input Stage3 = "?D, @DEBUG
              "0 Stack top = "?D, @SDEBUG
              "0 Stack top-1 = "?sD,s @SDEBUG
              v pop and loop over top element, which is array of column code
              NU Store the column number in X
              yv Loop over each character in the column
              N₄+₄*X+V Set Y to (rowNumber+1000)*1000+X, where X is the column number. This result is used for sorting.
              "1 Stack top = "?D, @SDEBUG
              "1 Stack top = "?D, @SDEBUG
              D Duplicate top element (which is now [0-9a-z])
              y Push y (special loop variable)
              "Character = "?D, @DEBUG
              k Push indexOf y in [0-9a-z]
              "Index = "?D, @DEBUG
              "2.1 Stack top = "?D, @SDEBUG
              "2.1 Stack top-1 = "?sD,s @SDEBUG
              D Duplicate index.
              32‹i index < 32. This uses up one copy of index
              b Push the index in binary. This uses the second copy of index.
              Dg Get the length of the binary number
              5s- 5 - length
              0s×ì Add 5-length 0s to the start of the binary number
              "Binary = "?D, @SDEBUG
              R Reverse the binary string. This gives the proper transposed output.
              X0Qi If X (which is set to the column number) == 0
              ¶ì Stick a linebreak at the beginning of the binary string
              }
              Y Push Y (the sort prefix).
              ð Push a space character
              «ì This gives "<row prefix> <binary representation of row>"
              "2.5 Stack top = "?D, @SDEBUG
              "2.5 Stack top-1 = "?sD,s @SDEBUG
              "Pushing '"?D?"'", @DEBUG
              ˆ Push "<row prefix>|<binary representation of row>" to global array
              "2.6 Stack top = "?D, @SDEBUG
              "2.6 Stack top-1 = "?sD,s @SDEBUG
              ] Close all blocks
              ¯ Push global array to stack and sort it.
              "Sorted Data = "?D, @DEBUG
              ε Map. This block removes the row numbers
              # Split on spaces
              θ Get the last element

              J Join with ""
              '1'█:'0'.: @DEBUG pretty print





              share|improve this answer



















              • 1




                Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
                – Jonathan Frech
                7 hours ago











              • One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
                – Jonathan Frech
                7 hours ago










              • I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
                – kerwizzy
                6 hours ago










              • Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
                – Jonathan Allan
                3 hours ago










              • Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
                – Kevin Cruijssen
                2 hours ago












              up vote
              5
              down vote










              up vote
              5
              down vote










              05AB1E, 148 132 bytes



              I'm a highschool student and this was my first time for both golfing and using 05AB1E, so comments are appreciated!



              "yy"¾38×:'yð:žhA«DUsð«#εN>≠iDнXsk4+s¦s0s×ì}}'w¾2×:'x¾3×:J'zð:ð«#DéθgUεDgXs-0s׫}vNUyvN₄+₄*X+VDykD32‹ibDg5s-0s×ìRX0Qi¶ì}Yð«ìˆ]¯ε#θJ


              Try it online!



              Try it online!



              Outputs the transposed matrix as multiple output lines of 1s and 0s. If you want pretty-printed output, add J'1'█:'0'.: at the end.



              Will add extra zeros.



              Explanation



              (I'm calling "rows" and "columns" opposite of what you might expect because it generates the transposed matrix)



              The basic algorithm is:



              1. Replace "yy" with 38 0s

              2. Split on "y" and and expand the 0-runs.

              3. Replace "w" and "x"

              4. Figure out the longest column (that is, the longest string between z's) and pad all the other columns so they are that length. (This is necessary because of how the algorithm below works)

              5. Split on z

              6. At this point, the input string is an array of columns where each column is a string of [0-9a-v], where each column is the same length.

              7. The algorithm to get it into the output format is to

                1. Convert the characters to numbers by using indexOf in a lookup string

                2. Convert the characters to binary and then pad to length 5

                3. If it is the first column, add a linebreak before the binary number

                4. Add a prefix to the beginning of the binary string that stores the row and then the column of the character.

                5. Push the binary string with prefix to 05AB1E's "global array" register/variable


              8. Sort the global array. The prefix string, which determines the sort order, will make sure everything ends up in the right order and the linebreaks are in the right places.

              9. Remove the prefix string from each element of the global array

              10. Join the array with "" and print it.

              There are some other minor details you can see below in the expanded code. Everything after the tabs at the end of a line is a comment and can be ignored. (This comment scheme is not part of 05AB1E, by the way. I did it this way because it looked nice.) Lines that have comments starting with "@" are for debugging purposes and can be omitted without changing the final output.



              "yy"¾38×: Replace "yy" with 38 0's. (y is the 34th character in the index, so need to add 34+4 = 38). ¾ is initialized to zero, which saves one byte from typing '038
              'yð: Replace "y" with " "
              "Replaced input Stage1 = "?D, @DEBUG

              žhA« Pushes [0-9a-z]
              DU Set X to [0-9a-z] and leave [0-9a-z] on the stack.
              s Swap top two elements. Now the stack is [0-9a-z],input

              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split input on " ", which "y" has been replaced with
              ε Map. This map replaces the y runs
              "Element = "?D, @DEBUG
              "N = "?N, @DEBUG
              N>≠i If N != 0
              "Replacing!", @DEBUG
              Dн Get the first letter
              X Push X
              s Swap
              k X (which is [0-9a-z]) .indexOf(firstLetter)
              "indexOf run token = "?D, @DEBUG
              4+ Add 4 to the index, now becoming the number of zeros to add
              s Swap. Now top is the string between runs
              ¦ Remove the first character
              s Swap again. Now the top is the number of zeros to add.
              0s×ì Add that many zeros to the start of the element.
              "Element Replaced = "?D, @DEBUG
              }
              }
              'w¾2×: Need to do this replacement after the y replacement so stuff like yw gets parsed properly. Again, ¾ is zero.
              'x¾3×:
              J Join with ""
              "Replaced input Stage2 = "?D, @DEBUG
              'zð: Replace "z" with " "
              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split on space. (Can't do split on z because it splits on z+)
              DéθgU Get max length and store it in X
              "Max length = "?X, @DEBUG
              ε Map
              DgXs- max column length - this column length
              "Zeros to add = "?D, @DEBUG
              0s׫ Add 0s to the end of the column so it is the same length as the longest one.
              }
              "Replaced input Stage3 = "?D, @DEBUG
              "0 Stack top = "?D, @SDEBUG
              "0 Stack top-1 = "?sD,s @SDEBUG
              v pop and loop over top element, which is array of column code
              NU Store the column number in X
              yv Loop over each character in the column
              N₄+₄*X+V Set Y to (rowNumber+1000)*1000+X, where X is the column number. This result is used for sorting.
              "1 Stack top = "?D, @SDEBUG
              "1 Stack top = "?D, @SDEBUG
              D Duplicate top element (which is now [0-9a-z])
              y Push y (special loop variable)
              "Character = "?D, @DEBUG
              k Push indexOf y in [0-9a-z]
              "Index = "?D, @DEBUG
              "2.1 Stack top = "?D, @SDEBUG
              "2.1 Stack top-1 = "?sD,s @SDEBUG
              D Duplicate index.
              32‹i index < 32. This uses up one copy of index
              b Push the index in binary. This uses the second copy of index.
              Dg Get the length of the binary number
              5s- 5 - length
              0s×ì Add 5-length 0s to the start of the binary number
              "Binary = "?D, @SDEBUG
              R Reverse the binary string. This gives the proper transposed output.
              X0Qi If X (which is set to the column number) == 0
              ¶ì Stick a linebreak at the beginning of the binary string
              }
              Y Push Y (the sort prefix).
              ð Push a space character
              «ì This gives "<row prefix> <binary representation of row>"
              "2.5 Stack top = "?D, @SDEBUG
              "2.5 Stack top-1 = "?sD,s @SDEBUG
              "Pushing '"?D?"'", @DEBUG
              ˆ Push "<row prefix>|<binary representation of row>" to global array
              "2.6 Stack top = "?D, @SDEBUG
              "2.6 Stack top-1 = "?sD,s @SDEBUG
              ] Close all blocks
              ¯ Push global array to stack and sort it.
              "Sorted Data = "?D, @DEBUG
              ε Map. This block removes the row numbers
              # Split on spaces
              θ Get the last element

              J Join with ""
              '1'█:'0'.: @DEBUG pretty print





              share|improve this answer
















              05AB1E, 148 132 bytes



              I'm a highschool student and this was my first time for both golfing and using 05AB1E, so comments are appreciated!



              "yy"¾38×:'yð:žhA«DUsð«#εN>≠iDнXsk4+s¦s0s×ì}}'w¾2×:'x¾3×:J'zð:ð«#DéθgUεDgXs-0s׫}vNUyvN₄+₄*X+VDykD32‹ibDg5s-0s×ìRX0Qi¶ì}Yð«ìˆ]¯ε#θJ


              Try it online!



              Try it online!



              Outputs the transposed matrix as multiple output lines of 1s and 0s. If you want pretty-printed output, add J'1'█:'0'.: at the end.



              Will add extra zeros.



              Explanation



              (I'm calling "rows" and "columns" opposite of what you might expect because it generates the transposed matrix)



              The basic algorithm is:



              1. Replace "yy" with 38 0s

              2. Split on "y" and and expand the 0-runs.

              3. Replace "w" and "x"

              4. Figure out the longest column (that is, the longest string between z's) and pad all the other columns so they are that length. (This is necessary because of how the algorithm below works)

              5. Split on z

              6. At this point, the input string is an array of columns where each column is a string of [0-9a-v], where each column is the same length.

              7. The algorithm to get it into the output format is to

                1. Convert the characters to numbers by using indexOf in a lookup string

                2. Convert the characters to binary and then pad to length 5

                3. If it is the first column, add a linebreak before the binary number

                4. Add a prefix to the beginning of the binary string that stores the row and then the column of the character.

                5. Push the binary string with prefix to 05AB1E's "global array" register/variable


              8. Sort the global array. The prefix string, which determines the sort order, will make sure everything ends up in the right order and the linebreaks are in the right places.

              9. Remove the prefix string from each element of the global array

              10. Join the array with "" and print it.

              There are some other minor details you can see below in the expanded code. Everything after the tabs at the end of a line is a comment and can be ignored. (This comment scheme is not part of 05AB1E, by the way. I did it this way because it looked nice.) Lines that have comments starting with "@" are for debugging purposes and can be omitted without changing the final output.



              "yy"¾38×: Replace "yy" with 38 0's. (y is the 34th character in the index, so need to add 34+4 = 38). ¾ is initialized to zero, which saves one byte from typing '038
              'yð: Replace "y" with " "
              "Replaced input Stage1 = "?D, @DEBUG

              žhA« Pushes [0-9a-z]
              DU Set X to [0-9a-z] and leave [0-9a-z] on the stack.
              s Swap top two elements. Now the stack is [0-9a-z],input

              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split input on " ", which "y" has been replaced with
              ε Map. This map replaces the y runs
              "Element = "?D, @DEBUG
              "N = "?N, @DEBUG
              N>≠i If N != 0
              "Replacing!", @DEBUG
              Dн Get the first letter
              X Push X
              s Swap
              k X (which is [0-9a-z]) .indexOf(firstLetter)
              "indexOf run token = "?D, @DEBUG
              4+ Add 4 to the index, now becoming the number of zeros to add
              s Swap. Now top is the string between runs
              ¦ Remove the first character
              s Swap again. Now the top is the number of zeros to add.
              0s×ì Add that many zeros to the start of the element.
              "Element Replaced = "?D, @DEBUG
              }
              }
              'w¾2×: Need to do this replacement after the y replacement so stuff like yw gets parsed properly. Again, ¾ is zero.
              'x¾3×:
              J Join with ""
              "Replaced input Stage2 = "?D, @DEBUG
              'zð: Replace "z" with " "
              ð« Append a space so the below splitter works even if there are no other spaces.
              # Split on space. (Can't do split on z because it splits on z+)
              DéθgU Get max length and store it in X
              "Max length = "?X, @DEBUG
              ε Map
              DgXs- max column length - this column length
              "Zeros to add = "?D, @DEBUG
              0s׫ Add 0s to the end of the column so it is the same length as the longest one.
              }
              "Replaced input Stage3 = "?D, @DEBUG
              "0 Stack top = "?D, @SDEBUG
              "0 Stack top-1 = "?sD,s @SDEBUG
              v pop and loop over top element, which is array of column code
              NU Store the column number in X
              yv Loop over each character in the column
              N₄+₄*X+V Set Y to (rowNumber+1000)*1000+X, where X is the column number. This result is used for sorting.
              "1 Stack top = "?D, @SDEBUG
              "1 Stack top = "?D, @SDEBUG
              D Duplicate top element (which is now [0-9a-z])
              y Push y (special loop variable)
              "Character = "?D, @DEBUG
              k Push indexOf y in [0-9a-z]
              "Index = "?D, @DEBUG
              "2.1 Stack top = "?D, @SDEBUG
              "2.1 Stack top-1 = "?sD,s @SDEBUG
              D Duplicate index.
              32‹i index < 32. This uses up one copy of index
              b Push the index in binary. This uses the second copy of index.
              Dg Get the length of the binary number
              5s- 5 - length
              0s×ì Add 5-length 0s to the start of the binary number
              "Binary = "?D, @SDEBUG
              R Reverse the binary string. This gives the proper transposed output.
              X0Qi If X (which is set to the column number) == 0
              ¶ì Stick a linebreak at the beginning of the binary string
              }
              Y Push Y (the sort prefix).
              ð Push a space character
              «ì This gives "<row prefix> <binary representation of row>"
              "2.5 Stack top = "?D, @SDEBUG
              "2.5 Stack top-1 = "?sD,s @SDEBUG
              "Pushing '"?D?"'", @DEBUG
              ˆ Push "<row prefix>|<binary representation of row>" to global array
              "2.6 Stack top = "?D, @SDEBUG
              "2.6 Stack top-1 = "?sD,s @SDEBUG
              ] Close all blocks
              ¯ Push global array to stack and sort it.
              "Sorted Data = "?D, @DEBUG
              ε Map. This block removes the row numbers
              # Split on spaces
              θ Get the last element

              J Join with ""
              '1'█:'0'.: @DEBUG pretty print






              share|improve this answer















              share|improve this answer



              share|improve this answer








              edited 6 hours ago


























              answered 8 hours ago









              kerwizzy

              513




              513







              • 1




                Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
                – Jonathan Frech
                7 hours ago











              • One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
                – Jonathan Frech
                7 hours ago










              • I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
                – kerwizzy
                6 hours ago










              • Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
                – Jonathan Allan
                3 hours ago










              • Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
                – Kevin Cruijssen
                2 hours ago












              • 1




                Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
                – Jonathan Frech
                7 hours ago











              • One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
                – Jonathan Frech
                7 hours ago










              • I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
                – kerwizzy
                6 hours ago










              • Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
                – Jonathan Allan
                3 hours ago










              • Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
                – Kevin Cruijssen
                2 hours ago







              1




              1




              Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
              – Jonathan Frech
              7 hours ago





              Hello and welcome to PPCG; very nice first post! Regarding your byte count: you are right. TIO even handily displays that the 148 characters are represented by 148 bytes using the 05AB1E code page.
              – Jonathan Frech
              7 hours ago













              One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
              – Jonathan Frech
              7 hours ago




              One small note: Most golfing languages implement implicit printing; I think you can ommit your last ,.
              – Jonathan Frech
              7 hours ago












              I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
              – kerwizzy
              6 hours ago




              I looked it over and made some improvements. The behavior will only be different (theoretically) for things with more than 1000 rows or columns, at which point the smaller program will do something unexpected.
              – kerwizzy
              6 hours ago












              Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
              – Jonathan Allan
              3 hours ago




              Not the easiest challenge to start on! Nice job, I imagine some of the 05AB1E stalwart will give some handy pointers when they come by.
              – Jonathan Allan
              3 hours ago












              Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
              – Kevin Cruijssen
              2 hours ago




              Welcome to PPCG and the world of 05AB1E. I don't have that much time right now, and I've only started using 05AB1E a few months ago, so I'm not that much of a pro yet either, but here some small things to golf: "yy" can be „yy (05AB1E has both a 2-char and 3-char string builtin). >≠ can be Ā (truthified, basically 0 remains 0 and everything else becomes 1). }} can be ] (close all loops and if-elses). I'm sure some of the pro 05AB1E golfers are able to golf more substantial things than me, possibly even halving the byte-count.
              – Kevin Cruijssen
              2 hours ago










              up vote
              3
              down vote














              APL (Dyalog Unicode), 87 80 bytes



              thangs to H.PWiz for saving 7 bytes



              a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞


              Try it online!



              NB: Takes the input as an upper case string.



              With pretty printed output



              Explanation



              a←⎕D,⎕A a is the string '0123...89ABCD...XYZ'
              ('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match) replaces X W and Yx with the corresponding number of '0's
              'Z'(≠⊆⊢) splits the string at each 'Z'
              ⊖(5/2)⊤a⍳⍵¨ decodes each substring (explained below)
              ,↓↑ reshapes and pads the result, returning a nested boolean array



              ⊖(5/2)⊤a⍳⍵¨
              ¨ ⍝ apply to each substring
              a⍳⍵ ⍝ return indecies of each charactor in a (i.e. '0'=>0, '9'=>9, 'B'=>11
              (5/2)⊤ ⍝ turn each of these into a 5-bit binary column
              ⊖ ⍝ reverse each column





              share|improve this answer























              • Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
                – H.PWiz
                12 hours ago










              • Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
                – jslip
                12 hours ago














              up vote
              3
              down vote














              APL (Dyalog Unicode), 87 80 bytes



              thangs to H.PWiz for saving 7 bytes



              a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞


              Try it online!



              NB: Takes the input as an upper case string.



              With pretty printed output



              Explanation



              a←⎕D,⎕A a is the string '0123...89ABCD...XYZ'
              ('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match) replaces X W and Yx with the corresponding number of '0's
              'Z'(≠⊆⊢) splits the string at each 'Z'
              ⊖(5/2)⊤a⍳⍵¨ decodes each substring (explained below)
              ,↓↑ reshapes and pads the result, returning a nested boolean array



              ⊖(5/2)⊤a⍳⍵¨
              ¨ ⍝ apply to each substring
              a⍳⍵ ⍝ return indecies of each charactor in a (i.e. '0'=>0, '9'=>9, 'B'=>11
              (5/2)⊤ ⍝ turn each of these into a 5-bit binary column
              ⊖ ⍝ reverse each column





              share|improve this answer























              • Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
                – H.PWiz
                12 hours ago










              • Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
                – jslip
                12 hours ago












              up vote
              3
              down vote










              up vote
              3
              down vote










              APL (Dyalog Unicode), 87 80 bytes



              thangs to H.PWiz for saving 7 bytes



              a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞


              Try it online!



              NB: Takes the input as an upper case string.



              With pretty printed output



              Explanation



              a←⎕D,⎕A a is the string '0123...89ABCD...XYZ'
              ('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match) replaces X W and Yx with the corresponding number of '0's
              'Z'(≠⊆⊢) splits the string at each 'Z'
              ⊖(5/2)⊤a⍳⍵¨ decodes each substring (explained below)
              ,↓↑ reshapes and pads the result, returning a nested boolean array



              ⊖(5/2)⊤a⍳⍵¨
              ¨ ⍝ apply to each substring
              a⍳⍵ ⍝ return indecies of each charactor in a (i.e. '0'=>0, '9'=>9, 'B'=>11
              (5/2)⊤ ⍝ turn each of these into a 5-bit binary column
              ⊖ ⍝ reverse each column





              share|improve this answer
















              APL (Dyalog Unicode), 87 80 bytes



              thangs to H.PWiz for saving 7 bytes



              a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞


              Try it online!



              NB: Takes the input as an upper case string.



              With pretty printed output



              Explanation



              a←⎕D,⎕A a is the string '0123...89ABCD...XYZ'
              ('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match) replaces X W and Yx with the corresponding number of '0's
              'Z'(≠⊆⊢) splits the string at each 'Z'
              ⊖(5/2)⊤a⍳⍵¨ decodes each substring (explained below)
              ,↓↑ reshapes and pads the result, returning a nested boolean array



              ⊖(5/2)⊤a⍳⍵¨
              ¨ ⍝ apply to each substring
              a⍳⍵ ⍝ return indecies of each charactor in a (i.e. '0'=>0, '9'=>9, 'B'=>11
              (5/2)⊤ ⍝ turn each of these into a 5-bit binary column
              ⊖ ⍝ reverse each column






              share|improve this answer















              share|improve this answer



              share|improve this answer








              edited 12 hours ago


























              answered 13 hours ago









              jslip

              4416




              4416











              • Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
                – H.PWiz
                12 hours ago










              • Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
                – jslip
                12 hours ago
















              • Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
                – H.PWiz
                12 hours ago










              • Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
                – jslip
                12 hours ago















              Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
              – H.PWiz
              12 hours ago




              Here is a 7 byte saving: a←⎕D,⎕A⋄,↓↑⊖(5/2)⊤a⍳⍵¨'Z'(≠⊆⊢)('Y.|W|X'⎕R'0'/⍨0::2+'WX'⍳⍵⋄4+a⍳1⊃⍵⍵.Match)⍞. The error catch also doesn't seem very golfy
              – H.PWiz
              12 hours ago












              Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
              – jslip
              12 hours ago




              Thanks @H.PWiz. Yeah I don't like the error catch either but otherwise I was using two regex replaces.
              – jslip
              12 hours ago










              up vote
              2
              down vote














              Perl 6, 156 142 bytes



              14 bytes saved thanks to Jo King. (Also fixed a little bug with parsing the y and added a prettifier.)



              Fixed the buggy parsing of y[wxy].





              s:g/y(.)/0000 x:36(~$0)/;s:g/x/w0/;s:g/w/00/;s/$/z/;map 
              .flatmap::32($_).fmt("%05b").flip.comb,[Z] .split("z").map: (*~0 x.chars).comb


              Try it online!



              The line break is there just to make the text fit on the screen. It is not a part of the program.



              How does it work



              It is an anonymous function that takes a mutable string. (This makes using the function a little bit peculiar, because you can give it only variables, not literals.) After some work, it returns a list of lists containing 0's and 1's, with the same meaning as in the original post.



              The input string comes in in the variable $_. We start by using a series of substitution statements on it in order to get rid of all of those shorthands for various numbers of zeroes. First, we need to sort out the y, because in the case of yx or yw, the w (or x) does not constitute a shorthand by itself. We search for y(.) (y and one character, which it remembers) and replace it by 000"0"x:36(~$0): the three zeroes are copied verbatim, then we convert the next character from base 36 to base 10 (:36(~$0)) and add that many more zeroes. Then, we replace the w's using s:g/w/00/, and the x's using s:g/x/000/. Finally, with s/$/z/, we add a z onto the end, adding a whole lot of empty lines to the bottom. (We'll see the reason later.)



              The rest is just a big map statement. We're mapping over .split("z").map: (*~0 x.chars).comb}), which is the input string (without zero shorthands), splitted into lines at z, with each line being first padded with 0 x.chars (tons of zeroes, namely as many as is the total length of the input string) on the right and then broken down into a list of individual characters (.comb). Finally, we transpose it with [Z] (reduce with zip). Zipping ends as soon as the shortest list is depleted, which results in all lines having the same length. (The number of useless trailing zeroes on the right is equal to the length of the shortest line. Also, this transposition trick fails for a "matrix" with only one row. That's why we forcibly added another row at the end before.)



              Now, we just map over the rows (columns of the original matrix) and replace each character encountered with the corresponding 5 bits. That is done using :32($_) (base 32 to base 10) .fmt("%05b") (format as a bitstring of width 5, padded with zeroes) .flip (reverse the string, because the LSB is in the top row, not the bottom) .comb (break the string into a list of characters). We have used .flatmap, which flattens the resulting list (otherwise we would get a list of lists in each column). The transpose of the result is then implicitly returned.



              (I feel a little bit bad because of abusing the possibility of trailing zeroes so hard. But it reduced the bytecount quite considerably :—).)






              share|improve this answer























              • 142 bytes
                – Jo King
                yesterday










              • @JoKing — Oh yes, thank you very much!
                – Ramillies
                yesterday










              • Fails for 1yx1 and 1yw1
                – Jonathan Allan
                19 hours ago










              • @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
                – Ramillies
                19 hours ago











              • You can replace the 000 in the y substitution with x
                – Jo King
                9 hours ago














              up vote
              2
              down vote














              Perl 6, 156 142 bytes



              14 bytes saved thanks to Jo King. (Also fixed a little bug with parsing the y and added a prettifier.)



              Fixed the buggy parsing of y[wxy].





              s:g/y(.)/0000 x:36(~$0)/;s:g/x/w0/;s:g/w/00/;s/$/z/;map 
              .flatmap::32($_).fmt("%05b").flip.comb,[Z] .split("z").map: (*~0 x.chars).comb


              Try it online!



              The line break is there just to make the text fit on the screen. It is not a part of the program.



              How does it work



              It is an anonymous function that takes a mutable string. (This makes using the function a little bit peculiar, because you can give it only variables, not literals.) After some work, it returns a list of lists containing 0's and 1's, with the same meaning as in the original post.



              The input string comes in in the variable $_. We start by using a series of substitution statements on it in order to get rid of all of those shorthands for various numbers of zeroes. First, we need to sort out the y, because in the case of yx or yw, the w (or x) does not constitute a shorthand by itself. We search for y(.) (y and one character, which it remembers) and replace it by 000"0"x:36(~$0): the three zeroes are copied verbatim, then we convert the next character from base 36 to base 10 (:36(~$0)) and add that many more zeroes. Then, we replace the w's using s:g/w/00/, and the x's using s:g/x/000/. Finally, with s/$/z/, we add a z onto the end, adding a whole lot of empty lines to the bottom. (We'll see the reason later.)



              The rest is just a big map statement. We're mapping over .split("z").map: (*~0 x.chars).comb}), which is the input string (without zero shorthands), splitted into lines at z, with each line being first padded with 0 x.chars (tons of zeroes, namely as many as is the total length of the input string) on the right and then broken down into a list of individual characters (.comb). Finally, we transpose it with [Z] (reduce with zip). Zipping ends as soon as the shortest list is depleted, which results in all lines having the same length. (The number of useless trailing zeroes on the right is equal to the length of the shortest line. Also, this transposition trick fails for a "matrix" with only one row. That's why we forcibly added another row at the end before.)



              Now, we just map over the rows (columns of the original matrix) and replace each character encountered with the corresponding 5 bits. That is done using :32($_) (base 32 to base 10) .fmt("%05b") (format as a bitstring of width 5, padded with zeroes) .flip (reverse the string, because the LSB is in the top row, not the bottom) .comb (break the string into a list of characters). We have used .flatmap, which flattens the resulting list (otherwise we would get a list of lists in each column). The transpose of the result is then implicitly returned.



              (I feel a little bit bad because of abusing the possibility of trailing zeroes so hard. But it reduced the bytecount quite considerably :—).)






              share|improve this answer























              • 142 bytes
                – Jo King
                yesterday










              • @JoKing — Oh yes, thank you very much!
                – Ramillies
                yesterday










              • Fails for 1yx1 and 1yw1
                – Jonathan Allan
                19 hours ago










              • @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
                – Ramillies
                19 hours ago











              • You can replace the 000 in the y substitution with x
                – Jo King
                9 hours ago












              up vote
              2
              down vote










              up vote
              2
              down vote










              Perl 6, 156 142 bytes



              14 bytes saved thanks to Jo King. (Also fixed a little bug with parsing the y and added a prettifier.)



              Fixed the buggy parsing of y[wxy].





              s:g/y(.)/0000 x:36(~$0)/;s:g/x/w0/;s:g/w/00/;s/$/z/;map 
              .flatmap::32($_).fmt("%05b").flip.comb,[Z] .split("z").map: (*~0 x.chars).comb


              Try it online!



              The line break is there just to make the text fit on the screen. It is not a part of the program.



              How does it work



              It is an anonymous function that takes a mutable string. (This makes using the function a little bit peculiar, because you can give it only variables, not literals.) After some work, it returns a list of lists containing 0's and 1's, with the same meaning as in the original post.



              The input string comes in in the variable $_. We start by using a series of substitution statements on it in order to get rid of all of those shorthands for various numbers of zeroes. First, we need to sort out the y, because in the case of yx or yw, the w (or x) does not constitute a shorthand by itself. We search for y(.) (y and one character, which it remembers) and replace it by 000"0"x:36(~$0): the three zeroes are copied verbatim, then we convert the next character from base 36 to base 10 (:36(~$0)) and add that many more zeroes. Then, we replace the w's using s:g/w/00/, and the x's using s:g/x/000/. Finally, with s/$/z/, we add a z onto the end, adding a whole lot of empty lines to the bottom. (We'll see the reason later.)



              The rest is just a big map statement. We're mapping over .split("z").map: (*~0 x.chars).comb}), which is the input string (without zero shorthands), splitted into lines at z, with each line being first padded with 0 x.chars (tons of zeroes, namely as many as is the total length of the input string) on the right and then broken down into a list of individual characters (.comb). Finally, we transpose it with [Z] (reduce with zip). Zipping ends as soon as the shortest list is depleted, which results in all lines having the same length. (The number of useless trailing zeroes on the right is equal to the length of the shortest line. Also, this transposition trick fails for a "matrix" with only one row. That's why we forcibly added another row at the end before.)



              Now, we just map over the rows (columns of the original matrix) and replace each character encountered with the corresponding 5 bits. That is done using :32($_) (base 32 to base 10) .fmt("%05b") (format as a bitstring of width 5, padded with zeroes) .flip (reverse the string, because the LSB is in the top row, not the bottom) .comb (break the string into a list of characters). We have used .flatmap, which flattens the resulting list (otherwise we would get a list of lists in each column). The transpose of the result is then implicitly returned.



              (I feel a little bit bad because of abusing the possibility of trailing zeroes so hard. But it reduced the bytecount quite considerably :—).)






              share|improve this answer
















              Perl 6, 156 142 bytes



              14 bytes saved thanks to Jo King. (Also fixed a little bug with parsing the y and added a prettifier.)



              Fixed the buggy parsing of y[wxy].





              s:g/y(.)/0000 x:36(~$0)/;s:g/x/w0/;s:g/w/00/;s/$/z/;map 
              .flatmap::32($_).fmt("%05b").flip.comb,[Z] .split("z").map: (*~0 x.chars).comb


              Try it online!



              The line break is there just to make the text fit on the screen. It is not a part of the program.



              How does it work



              It is an anonymous function that takes a mutable string. (This makes using the function a little bit peculiar, because you can give it only variables, not literals.) After some work, it returns a list of lists containing 0's and 1's, with the same meaning as in the original post.



              The input string comes in in the variable $_. We start by using a series of substitution statements on it in order to get rid of all of those shorthands for various numbers of zeroes. First, we need to sort out the y, because in the case of yx or yw, the w (or x) does not constitute a shorthand by itself. We search for y(.) (y and one character, which it remembers) and replace it by 000"0"x:36(~$0): the three zeroes are copied verbatim, then we convert the next character from base 36 to base 10 (:36(~$0)) and add that many more zeroes. Then, we replace the w's using s:g/w/00/, and the x's using s:g/x/000/. Finally, with s/$/z/, we add a z onto the end, adding a whole lot of empty lines to the bottom. (We'll see the reason later.)



              The rest is just a big map statement. We're mapping over .split("z").map: (*~0 x.chars).comb}), which is the input string (without zero shorthands), splitted into lines at z, with each line being first padded with 0 x.chars (tons of zeroes, namely as many as is the total length of the input string) on the right and then broken down into a list of individual characters (.comb). Finally, we transpose it with [Z] (reduce with zip). Zipping ends as soon as the shortest list is depleted, which results in all lines having the same length. (The number of useless trailing zeroes on the right is equal to the length of the shortest line. Also, this transposition trick fails for a "matrix" with only one row. That's why we forcibly added another row at the end before.)



              Now, we just map over the rows (columns of the original matrix) and replace each character encountered with the corresponding 5 bits. That is done using :32($_) (base 32 to base 10) .fmt("%05b") (format as a bitstring of width 5, padded with zeroes) .flip (reverse the string, because the LSB is in the top row, not the bottom) .comb (break the string into a list of characters). We have used .flatmap, which flattens the resulting list (otherwise we would get a list of lists in each column). The transpose of the result is then implicitly returned.



              (I feel a little bit bad because of abusing the possibility of trailing zeroes so hard. But it reduced the bytecount quite considerably :—).)







              share|improve this answer















              share|improve this answer



              share|improve this answer








              edited 19 hours ago


























              answered yesterday









              Ramillies

              1,291411




              1,291411











              • 142 bytes
                – Jo King
                yesterday










              • @JoKing — Oh yes, thank you very much!
                – Ramillies
                yesterday










              • Fails for 1yx1 and 1yw1
                – Jonathan Allan
                19 hours ago










              • @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
                – Ramillies
                19 hours ago











              • You can replace the 000 in the y substitution with x
                – Jo King
                9 hours ago
















              • 142 bytes
                – Jo King
                yesterday










              • @JoKing — Oh yes, thank you very much!
                – Ramillies
                yesterday










              • Fails for 1yx1 and 1yw1
                – Jonathan Allan
                19 hours ago










              • @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
                – Ramillies
                19 hours ago











              • You can replace the 000 in the y substitution with x
                – Jo King
                9 hours ago















              142 bytes
              – Jo King
              yesterday




              142 bytes
              – Jo King
              yesterday












              @JoKing — Oh yes, thank you very much!
              – Ramillies
              yesterday




              @JoKing — Oh yes, thank you very much!
              – Ramillies
              yesterday












              Fails for 1yx1 and 1yw1
              – Jonathan Allan
              19 hours ago




              Fails for 1yx1 and 1yw1
              – Jonathan Allan
              19 hours ago












              @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
              – Ramillies
              19 hours ago





              @JonathanAllan, you're right, thank you. I'll fix it in a moment. (I first thought for some reason that there could be only y[0-9a-v] and when I found that it's not the case, I just added a quick (and wrong) fix.)
              – Ramillies
              19 hours ago













              You can replace the 000 in the y substitution with x
              – Jo King
              9 hours ago




              You can replace the 000 in the y substitution with x
              – Jo King
              9 hours ago










              up vote
              2
              down vote














              Jelly, 66 bytes



              Yowza!



              ØBiⱮ+
              Œuœṣ⁾YYj38Żṣ”YµḢç3;)Fṣ”Wj2ṣ”Xj3”0ẋ$¹OƑ?€Fṣ”Zµȯ”0ç31BḊ€UZ)Ẏz0


              A monadic link which yields a transposed version as a list of lists (add Z to the end to transpose back).



              Try it online! Or see the test-suite (with pretty printed output).






              share|improve this answer



























                up vote
                2
                down vote














                Jelly, 66 bytes



                Yowza!



                ØBiⱮ+
                Œuœṣ⁾YYj38Żṣ”YµḢç3;)Fṣ”Wj2ṣ”Xj3”0ẋ$¹OƑ?€Fṣ”Zµȯ”0ç31BḊ€UZ)Ẏz0


                A monadic link which yields a transposed version as a list of lists (add Z to the end to transpose back).



                Try it online! Or see the test-suite (with pretty printed output).






                share|improve this answer

























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote










                  Jelly, 66 bytes



                  Yowza!



                  ØBiⱮ+
                  Œuœṣ⁾YYj38Żṣ”YµḢç3;)Fṣ”Wj2ṣ”Xj3”0ẋ$¹OƑ?€Fṣ”Zµȯ”0ç31BḊ€UZ)Ẏz0


                  A monadic link which yields a transposed version as a list of lists (add Z to the end to transpose back).



                  Try it online! Or see the test-suite (with pretty printed output).






                  share|improve this answer
















                  Jelly, 66 bytes



                  Yowza!



                  ØBiⱮ+
                  Œuœṣ⁾YYj38Żṣ”YµḢç3;)Fṣ”Wj2ṣ”Xj3”0ẋ$¹OƑ?€Fṣ”Zµȯ”0ç31BḊ€UZ)Ẏz0


                  A monadic link which yields a transposed version as a list of lists (add Z to the end to transpose back).



                  Try it online! Or see the test-suite (with pretty printed output).







                  share|improve this answer















                  share|improve this answer



                  share|improve this answer








                  edited 13 hours ago


























                  answered 13 hours ago









                  Jonathan Allan

                  46.5k433155




                  46.5k433155




















                      up vote
                      0
                      down vote














                      Python 2, 249 bytes





                      def f(s,Z='0'):
                      while 'y'in s:i=s.find('y');s=s[:i]+4*Z+Z*int(s[i+1],36)+s[i+2:]
                      t=s.replace('w',2*Z).replace('x',3*Z).split('z')
                      return map(''.join,zip(*[[(Z*5+bin(int(c,32))[2:])[-5:][::-1]for c in r]+[Z*5]*(max(map(len,t))-len(r))for r in t]))


                      Try it online!






                      share|improve this answer





















                      • There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                        – Jonathan Frech
                        7 hours ago














                      up vote
                      0
                      down vote














                      Python 2, 249 bytes





                      def f(s,Z='0'):
                      while 'y'in s:i=s.find('y');s=s[:i]+4*Z+Z*int(s[i+1],36)+s[i+2:]
                      t=s.replace('w',2*Z).replace('x',3*Z).split('z')
                      return map(''.join,zip(*[[(Z*5+bin(int(c,32))[2:])[-5:][::-1]for c in r]+[Z*5]*(max(map(len,t))-len(r))for r in t]))


                      Try it online!






                      share|improve this answer





















                      • There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                        – Jonathan Frech
                        7 hours ago












                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote










                      Python 2, 249 bytes





                      def f(s,Z='0'):
                      while 'y'in s:i=s.find('y');s=s[:i]+4*Z+Z*int(s[i+1],36)+s[i+2:]
                      t=s.replace('w',2*Z).replace('x',3*Z).split('z')
                      return map(''.join,zip(*[[(Z*5+bin(int(c,32))[2:])[-5:][::-1]for c in r]+[Z*5]*(max(map(len,t))-len(r))for r in t]))


                      Try it online!






                      share|improve this answer














                      Python 2, 249 bytes





                      def f(s,Z='0'):
                      while 'y'in s:i=s.find('y');s=s[:i]+4*Z+Z*int(s[i+1],36)+s[i+2:]
                      t=s.replace('w',2*Z).replace('x',3*Z).split('z')
                      return map(''.join,zip(*[[(Z*5+bin(int(c,32))[2:])[-5:][::-1]for c in r]+[Z*5]*(max(map(len,t))-len(r))for r in t]))


                      Try it online!







                      share|improve this answer













                      share|improve this answer



                      share|improve this answer











                      answered 15 hours ago









                      Chas Brown

                      3,510216




                      3,510216











                      • There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                        – Jonathan Frech
                        7 hours ago
















                      • There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                        – Jonathan Frech
                        7 hours ago















                      There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                      – Jonathan Frech
                      7 hours ago




                      There is a superfluous space in while 'y'in. I think the subscript [-5:][::-1] can be golfed to [:-6:-1]. The return statement can be put on the previous line.
                      – Jonathan Frech
                      7 hours ago












                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f169976%2fdecrypt-the-extended-wechsler-format%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      pylint3 and pip3 broken

                      Missing snmpget and snmpwalk

                      How to enroll fingerprints to Ubuntu 17.10 with VFS491