Decrypt the extended Wechsler format

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))

05AB1E, 148 132 98 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ð:žLRDUsð«#εNĀiDнXsk4+s¦sú]'W¾2×:'X¾3×:J'Z¶:.Bð¾:vNUyvDykDNX‚Š32VY‹iY+b¦RX_i¶ì}‚ˆ]¯{€¦˜J

Try it online!

Try it online!

Try it online!

Takes input as uppercase and outputs the transposed matrix as multiple output lines of 1s and 0s. May add extra zeros.

If you want to test with lowercase strings, add u in the TIO header.

If you want pretty-printed output, add '1'█:'0'.: in the TIO footer.

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

žLR                                             Pushes [0-9A-Za-z]
DU                                              Set X to [0-9A-Za-z] and leave [0-9A-Za-z] on the stack.
s                                               Swap top two elements. Now the stack is [0-9A-Za-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-Za-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.
        ú                                       Add that many spaces (will be replaced with zeros later) 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 "¶".
.B                                              "Squarify" command. Splits on \n and appends spaces to the end of each element so each is the same length. In this case, that is equivalent to adding zeros to the end of each column, which is what we want.
ð¾:                                             Replace spaces (which we used for padding above) with zeros.
"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              
        "1 Stack top = "?D,                     @SDEBUG
        "1 Stack top = "?D,                     @SDEBUG
        D                                       Duplicate top element (which is now [0-9A-Za-z])
        y                                       Push y (special loop variable)
        "Character = "?D,                       @DEBUG
        k                                       Push indexOf y in [0-9A-Za-z]
        "Index = "?D,                           @DEBUG
        "2.1 Stack top = "?D,                   @SDEBUG
        "2.1 Stack top-1 = "?sD,s               @SDEBUG
        D                                       Duplicate index.
        NX‚                                     Push [rowNumber,columnNumber]. This result is used for sorting.
        Š                                       Triple swap. The top of the stack is now sortPrefix, index, index
        32V                                     Set Y to 32
        Y‹i                                     index < 32. This uses up one copy of index
            Y+                                  Add 32 to the index
            b                                   Push the index in binary. This uses the second copy of index. 
            ¦                                   Remove the first character, which will be a 1 because we added 32. The result is now a padded binary string of length 5
            "Binary = "?D,                      @SDEBUG
            R                                   Reverse the binary string. This gives the proper transposed output. 
            X_i                                 This will only run if X (which is set to the column number) == 0. (Runs !X)
                ¶ì                              Stick a linebreak at the beginning of the binary string
            }
            "2.5 Stack top = "?D,               @SDEBUG
            "2.5 Stack top-1 = "?sD,s           @SDEBUG         
            ‚                                   At this point the top of the stack is sortPrefix,binaryString. This will combine the two into a list.
            "Pushing '"?D?"'",                  @DEBUG
            ˆ                                   Push [[rowNumber,columnNumber],binaryString] to global array
            "2.6 Stack top = "?D,               @SDEBUG
            "2.6 Stack top-1 = "?sD,s           @SDEBUG
        ]                                       Close all blocks
¯                                               Push global array

{                                               Sort global array. 
"Sorted Data = "?D,                             @DEBUG
€¦                                              Remove the sort prefix              
˜                                               Flatten. Before doing this, the array is in the format [[<binary string>],[<binary string>],[<binary string>],...]
J                                               Join with ""
'1'█:'0'.:                                      @DEBUG pretty print 

APL (Dyalog Unicode), 87 80 77 67 63 bytes

thanks to H.PWiz for saving 7 bytes and ngn for another 13 17.

a←⎕D,⎕A⋄,⍉↓⊖(5/2)⊤↑35(≠⊆⊢)a⍳'Y.|W|X'⎕R{'0'/⍨30 36|a⍳2↑⍵.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'/⍨+/30 36|a⍳2↑⍵.Match} replaces X W and Yx with the corresponding number of '0's (explained more below) 35(≠⊆⊢)a⍳ converts the string into vector of indecies in a and splits on 35 (i.e.) 'Z' creating a nested vector
converts the nested vector into a matrix padding ends with 0s
(5/2)⊤ converts each number into a binary vector resulting in a 3-dimensional matrix with binary vectors along the primary axis
reverses along the primary axis
reduces the rank of the matrix so it is 2-dimensional
,⍉ reshapes the result to the appropriate output

'Y.|W|X'⎕R{'0'/⍨30 36|a⍳2↑⍵.Match}
'Y.|W|X'⎕R                         ⍝ Regular expression replace. mathing the string.
                        2↑⍵.Match  ⍝ Takes matching string (either 'X' 'W' or 'Y.') and pads with spaces to length 2
                      a⍳           ⍝ Returns the indecies of each charactor in a. on the spaces this is 36 (length of a)
                30 36|             ⍝ Takes the remainders of the indecies when divided by 30 and 36 respectively. Overall 'W' -> 'W ' -> 32 36 -> 2 0, 'Y2' -> 'Y2' -> 34 2 -> 4 2.
           '0'/⍨                   ⍝ Make vector of repeating '0's with length equal to the sum of the result. '0'/⍨4 2 ≡ '000000'