Skip to main content
explained STDIN/OUT
Source Link
FlipTack
  • 14.7k
  • 23
  • 16

#Draw me a Brick Wall!

I'm drawing up a plan for my house extension - and I need a simple graphic for walls...

#The Challenge

Your task is to create a program, which takes an input of the wall's dimensions and draws a brick wall, in the style of the one below.

[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_

Please notice that the rows alternate between beginning on a full brick ([__]) and a half brick (_]), to create a more realistic, stable wall.

The input will be two integers, separated by a single comma, such as 4,3 or 2,6. You can assume both integers are positive and larger than 0.

The first integer specifies the width (in bricks) and the second specifies the height (in rows of bricks).

#Rules / Notes

  • This is , so the shortest code (in bytes) wins. However, don't feel like you have to beat everyone else to post your solution - I'd love to see your code!
  • Standard loopholes apply, no reading from external files.
  • You may optionally take the input with brackets/braces, for example (4,3) or [4,3] as long as you specify this in your answer.
  • You should take the input from STDIN and output on STDOUT - if your language does not have these, please use the nearest equivalent.

##Test Cases

Input: 1,1

[__]

Input: 2,4

[__][__]
_][__][_
[__][__]
_][__][_

Input: 5,10

[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_

#Example: Python 3, 65 bytes

This is somewhat golfed but still readable.

w,h=eval(input())
for i in range(h):print(('[__]','_][_')[i%2]*w)

#Draw me a Brick Wall!

I'm drawing up a plan for my house extension - and I need a simple graphic for walls...

#The Challenge

Your task is to create a program, which takes an input of the wall's dimensions and draws a brick wall, in the style of the one below.

[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_

Please notice that the rows alternate between beginning on a full brick ([__]) and a half brick (_]), to create a more realistic, stable wall.

The input will be two integers, separated by a single comma, such as 4,3 or 2,6. You can assume both integers are positive and larger than 0.

The first integer specifies the width (in bricks) and the second specifies the height (in rows of bricks).

#Rules / Notes

  • This is , so the shortest code (in bytes) wins. However, don't feel like you have to beat everyone else to post your solution - I'd love to see your code!
  • Standard loopholes apply, no reading from external files.
  • You may optionally take the input with brackets/braces, for example (4,3) or [4,3] as long as you specify this in your answer.

##Test Cases

Input: 1,1

[__]

Input: 2,4

[__][__]
_][__][_
[__][__]
_][__][_

Input: 5,10

[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_

#Example: Python 3, 65 bytes

This is somewhat golfed but still readable.

w,h=eval(input())
for i in range(h):print(('[__]','_][_')[i%2]*w)

#Draw me a Brick Wall!

I'm drawing up a plan for my house extension - and I need a simple graphic for walls...

#The Challenge

Your task is to create a program, which takes an input of the wall's dimensions and draws a brick wall, in the style of the one below.

[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_

Please notice that the rows alternate between beginning on a full brick ([__]) and a half brick (_]), to create a more realistic, stable wall.

The input will be two integers, separated by a single comma, such as 4,3 or 2,6. You can assume both integers are positive and larger than 0.

The first integer specifies the width (in bricks) and the second specifies the height (in rows of bricks).

#Rules / Notes

  • This is , so the shortest code (in bytes) wins. However, don't feel like you have to beat everyone else to post your solution - I'd love to see your code!
  • Standard loopholes apply, no reading from external files.
  • You may optionally take the input with brackets/braces, for example (4,3) or [4,3] as long as you specify this in your answer.
  • You should take the input from STDIN and output on STDOUT - if your language does not have these, please use the nearest equivalent.

##Test Cases

Input: 1,1

[__]

Input: 2,4

[__][__]
_][__][_
[__][__]
_][__][_

Input: 5,10

[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_

#Example: Python 3, 65 bytes

This is somewhat golfed but still readable.

w,h=eval(input())
for i in range(h):print(('[__]','_][_')[i%2]*w)
Source Link
FlipTack
  • 14.7k
  • 23
  • 16

#Draw me a Brick Wall!

I'm drawing up a plan for my house extension - and I need a simple graphic for walls...

#The Challenge

Your task is to create a program, which takes an input of the wall's dimensions and draws a brick wall, in the style of the one below.

[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_
[__][__][__][__]
_][__][__][__][_

Please notice that the rows alternate between beginning on a full brick ([__]) and a half brick (_]), to create a more realistic, stable wall.

The input will be two integers, separated by a single comma, such as 4,3 or 2,6. You can assume both integers are positive and larger than 0.

The first integer specifies the width (in bricks) and the second specifies the height (in rows of bricks).

#Rules / Notes

  • This is , so the shortest code (in bytes) wins. However, don't feel like you have to beat everyone else to post your solution - I'd love to see your code!
  • Standard loopholes apply, no reading from external files.
  • You may optionally take the input with brackets/braces, for example (4,3) or [4,3] as long as you specify this in your answer.

##Test Cases

Input: 1,1

[__]

Input: 2,4

[__][__]
_][__][_
[__][__]
_][__][_

Input: 5,10

[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_
[__][__][__][__][__]
_][__][__][__][__][_

#Example: Python 3, 65 bytes

This is somewhat golfed but still readable.

w,h=eval(input())
for i in range(h):print(('[__]','_][_')[i%2]*w)