Skip to main content
saved 1 byte
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 6160 bytes

-1 thanks to @MatthewJensen

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8g=k=>k--?'':g" X"['0x'+s>>k&1]+g(-~kk)+" X"['0x'+s>>k&1]:'')``(8)).join`
`

Try it online!Try it online!

Commented

a =>             // a[] = input array
a.map(s =>       // for each string s in a[]:
  ( g = k =>     //   g is recursive function taking a counter k
    k-- &? 8 ?      //   if k is not equal to 8:
0 (decrement it afterwards):
   ''   " X"[      //     stop theappend recursion
either ' ' or 'X':  
        '0x' + s //   else:    parse s as a hexadecimal string
      g(-~k) + >> k     //     do a recursiveright-shift callit withby k + 1position
      " X"[ & 1      //     append either 'and 'isolate orthe 'X':
least significant bit
      '0x'] + s //       parse// s as a hexadecimal string
end of lookup
      >>+ g(k)     //     append the right-shiftresult itof bya krecursive positioncall
    :    & 1       //       and isolate the least significant bitelse:
      ] ''         //     endstop ofthe lookuprecursion
  )`` (8)           //   initial call to g with k zero'ish= 8
).join`\n`       // end of map(); join with line-feeds

JavaScript (ES6), 61 bytes

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8?'':g(-~k)+" X"['0x'+s>>k&1])``).join`
`

Try it online!

Commented

a =>             // a[] = input array
a.map(s =>       // for each string s in a[]:
  ( g = k =>     //   g is recursive function taking a counter k
    k & 8 ?      //   if k is equal to 8:
      ''         //     stop the recursion
    :            //   else:
      g(-~k) +   //     do a recursive call with k + 1
      " X"[      //     append either ' ' or 'X':
        '0x' + s //       parse s as a hexadecimal string
        >> k     //       right-shift it by k position
        & 1      //       and isolate the least significant bit
      ]          //     end of lookup
  )``            //   initial call to g with k zero'ish
).join`\n`       // end of map(); join with line-feeds

JavaScript (ES6), 60 bytes

-1 thanks to @MatthewJensen

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k--?" X"['0x'+s>>k&1]+g(k):'')(8)).join`
`

Try it online!

Commented

a =>             // a[] = input array
a.map(s =>       // for each string s in a[]:
  ( g = k =>     //   g is recursive function taking a counter k
    k-- ?        //   if k is not equal to 0 (decrement it afterwards):
      " X"[      //     append either ' ' or 'X': 
        '0x' + s //       parse s as a hexadecimal string
        >> k     //       right-shift it by k position
        & 1      //       and isolate the least significant bit
      ]          //     end of lookup
      + g(k)     //     append the result of a recursive call
    :            //   else:
      ''         //     stop the recursion
  )(8)           //   initial call to g with k = 8
).join`\n`       // end of map(); join with line-feeds
added a commented version
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 61 bytes

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8?'':g(-~k)+" X"['0x'+s>>k&1])``).join`
`

Try it online!

Commented

a =>             // a[] = input array
a.map(s =>       // for each string s in a[]:
  ( g = k =>     //   g is recursive function taking a counter k
    k & 8 ?      //   if k is equal to 8:
      ''         //     stop the recursion
    :            //   else:
      g(-~k) +   //     do a recursive call with k + 1
      " X"[      //     append either ' ' or 'X':
        '0x' + s //       parse s as a hexadecimal string
        >> k     //       right-shift it by k position
        & 1      //       and isolate the least significant bit
      ]          //     end of lookup
  )``            //   initial call to g with k zero'ish
).join`\n`       // end of map(); join with line-feeds

JavaScript (ES6), 61 bytes

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8?'':g(-~k)+" X"['0x'+s>>k&1])``).join`
`

Try it online!

JavaScript (ES6), 61 bytes

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8?'':g(-~k)+" X"['0x'+s>>k&1])``).join`
`

Try it online!

Commented

a =>             // a[] = input array
a.map(s =>       // for each string s in a[]:
  ( g = k =>     //   g is recursive function taking a counter k
    k & 8 ?      //   if k is equal to 8:
      ''         //     stop the recursion
    :            //   else:
      g(-~k) +   //     do a recursive call with k + 1
      " X"[      //     append either ' ' or 'X':
        '0x' + s //       parse s as a hexadecimal string
        >> k     //       right-shift it by k position
        & 1      //       and isolate the least significant bit
      ]          //     end of lookup
  )``            //   initial call to g with k zero'ish
).join`\n`       // end of map(); join with line-feeds
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 61 bytes

Expects a list of 2-character hexadecimal strings.

a=>a.map(s=>(g=k=>k&8?'':g(-~k)+" X"['0x'+s>>k&1])``).join`
`

Try it online!