Skip to main content
added 56 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 3636 34 bytes

(' ','#.'$~#){~[:+/(-@[|.!@]{.0]$1-~$1:)/"2 

Try it online!Try it online!

-2 bytes thanks to Bubbler

We take input as a list of 2x2 matrices.

  • For each of them "2, draw a box of ones 1: of the same shape $ as the right inputelement-wise difference between the top-left and bottom-right coords ]-~, ie, the coords of the bottom right of the box.
  • Then rotate that down and to the right with 0 fill |.!-@]{.0 until the upper leftmost 1 is in the coords specified by the left arg -@[.
  • [:+/ Sum the resulting matrices elementwiseelement-wise. J guarantees they will be the same size by adding 0 fill to the right. This will produce a single matrix with integers 0, 1, 2, 3, etc. We'll use those to index into our ascii chars {~.
  • '#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.

J, 36 bytes

(' ','#.'$~#){~[:+/(-@[|.!.0]$1:)/"2 

Try it online!

We take input as a list of 2x2 matrices.

  • For each of them "2, draw a box of ones 1: of the same shape $ as the right input ], ie, the coords of the bottom right of the box.
  • Then rotate that down and to the right with 0 fill |.!.0 until the upper leftmost 1 is in the coords specified by the left arg -@[.
  • [:+/ Sum the resulting matrices elementwise. J guarantees they will be the same size by adding 0 fill to the right. This will produce a single matrix with integers 0, 1, 2, 3, etc. We'll use those to index into our ascii chars {~.
  • '#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.

J, 36 34 bytes

(' ','#.'$~#){~[:+/(-@]{.-~$1:)/"2 

Try it online!

-2 bytes thanks to Bubbler

We take input as a list of 2x2 matrices.

  • For each of them "2, draw a box of ones 1: of the same shape $ as the element-wise difference between the top-left and bottom-right coords -~.
  • Then rotate that down and to the right with 0 fill -@]{. until the upper leftmost 1 is in the coords specified by the left arg -@[.
  • [:+/ Sum the resulting matrices element-wise. J guarantees they will be the same size by adding 0 fill to the right. This will produce a single matrix with integers 0, 1, 2, 3, etc. We'll use those to index into our ascii chars {~.
  • '#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.
added 694 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 36 bytes

(' ','#.'$~#){~[:+/(-@[|.!.0]$1:)/"2 

Try it online!

We take input as a list of 2x2 matrices.

  • For each of them "2, draw a box of ones 1: of the same shape $ as the right input ], ie, the coords of the bottom right of the box.
  • Then rotate that down and to the right with 0 fill |.!.0 until the upper leftmost 1 is in the coords specified by the left arg -@[.
  • [:+/ Sum the resulting matrices elementwise. J guarantees they will be the same size by adding 0 fill to the right. This will produce a single matrix with integers 0, 1, 2, 3, etc. We'll use those to index into our ascii chars {~.
  • '#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.

J, 36 bytes

(' ','#.'$~#){~[:+/(-@[|.!.0]$1:)/"2 

Try it online!

J, 36 bytes

(' ','#.'$~#){~[:+/(-@[|.!.0]$1:)/"2 

Try it online!

We take input as a list of 2x2 matrices.

  • For each of them "2, draw a box of ones 1: of the same shape $ as the right input ], ie, the coords of the bottom right of the box.
  • Then rotate that down and to the right with 0 fill |.!.0 until the upper leftmost 1 is in the coords specified by the left arg -@[.
  • [:+/ Sum the resulting matrices elementwise. J guarantees they will be the same size by adding 0 fill to the right. This will produce a single matrix with integers 0, 1, 2, 3, etc. We'll use those to index into our ascii chars {~.
  • '#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 36 bytes

(' ','#.'$~#){~[:+/(-@[|.!.0]$1:)/"2 

Try it online!