Skip to main content

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it'sits binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (ASCII decimal code 32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you may not use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you may not use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to its binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (ASCII decimal code 32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you may not use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Tweeted twitter.com/StackCodeGolf/status/889707179791482880
added 1 character in body
Source Link
Oliver Ni
  • 10.6k
  • 3
  • 38
  • 107

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you cannotmay not use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you cannot use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you may not use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

added 101 characters in body
Source Link
TheLethalCoder
  • 7.2k
  • 27
  • 43

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you cannot use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you cannot use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.

How does this work?

  1. Convert each number to it's binary representation.
  2. Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
  3. Create a wall where the 1s are bricks and 0s are missing bricks.

A wall is a block of characters where any printable character represents a brick and a space (32) represents a missing brick. You may choose any character for the brick, it need not be distinct across the wall as long as it isn't a white space character. The missing brick character must be a space. For the example below I have used * for the bricks.

Example

Input:

[ 15, 7, 13, 11 ]
  1. [ 1111, 111, 1101, 1011 ]

  2. [ 1111, 0111, 1101, 1011 ]

  3. Output:

    ****
     ***
    ** *
    * **
    

Rules

  • Input must be taken in base 10, if your language accepts other bases you cannot use them.
  • Leading and trailing new lines are allowed.
  • Input may be taken as a list of integers, separate arguments or any reasonable format.
  • Output may be in any reasonable format: new line separated string, array of lines, 2d array etc.
  • Standard loopholes are disallowed.

Test Cases

Note that in the first test case all of layers have an empty brick at the end.

[ 14, 4, 6, 2 ]

*** 
 *  
 ** 
  * 

[ 1, 2, 4, 8, 16 ]

    *
   * 
  *  
 *   
*

[ 15, 11, 15, 15 ]

****
* **
****
****

[ 11, 10, 9, 8 ]

* **
* * 
*  *
*   

This is code golf so shortest code wins!

deleted 2 characters in body
Source Link
user41805
  • 13.2k
  • 6
  • 42
  • 88
Loading
Source Link
TheLethalCoder
  • 7.2k
  • 27
  • 43
Loading