19
2
You're given a rectangular grid of the characters .
and #
, like this:
..........
..#.......
....#..#..
...#......
..........
Your task is to fill the entire axis-aligned bounding box of the #
with further #
:
..........
..######..
..######..
..######..
..........
The axis-aligned bounding box is the smallest rectangle which contains all the #
.
Want more? Try Part II!
Rules
You may use any two distinct printable ASCII characters (0x20 to 0x7E, inclusive), in place of #
and .
. I'll continue referring to them as #
and .
for the remainder of the specification though.
Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.
You may assume that the input contains at least one #
and all lines are the same length.
You may write a program or a function and use any of the our standard methods of receiving input and providing output.
You may use any programming language, but note that these loopholes are forbidden by default.
This is code-golf, so the shortest valid answer – measured in bytes – wins.
Test Cases
Each test case has input and output next to each other.
# #
... ...
#.. #..
... ...
... ...
#.. ###
..# ###
.#. ###
#.. ###
..# ###
..... .....
.#.#. .###.
..... .....
... ...
.#. .#.
... .#.
.#. .#.
... ...
.......... ..........
.......... ..........
....#..... ....#.....
.......... ..........
.......... ..........
.......... ..........
....#..... ...##.....
...#...... ...##.....
.......... ..........
..#....... ..###.....
....#..... ..###.....
...#...... ..###.....
.......... ..........
..#....... ..######..
....#..#.. ..######..
...#...... ..######..
.........# ..########
..#....... ..########
....#..#.. ..########
...#...... ..########
What do you mean by "the format has to be consistent"? Does the input format need to be consistent with the output format or does it mean that the input format need to be consistent and the output format also need to be consistent? – Emigna – 2016-08-25T14:48:55.447
@Emigna the input and output formats need to be the same. – Martin Ender – 2016-08-25T15:32:39.247
@MartinEnder My program inputs a 2D char array and processes it. The outcome is still a 2D char array, but that is displayed by default as the array's contents, i.e. strings separated by newlines. Is that acceptable? Or should the displayed output be a string representation of that 2D array? – Luis Mendo – 2016-08-25T16:09:54.557
@LuisMendo I'd expect a string representation of the type. Whether the linefeed-separated strings are the natural string representation of the nested array in your language I can't say. (Although, since that doesn't appear to be a "reversible" representation, since your input format is different, probably not.) – Martin Ender – 2016-08-25T17:54:19.007
is graphical output allowed? – 12Me21 – 2017-02-04T16:02:28.540
@12Me21 No, I think ASCII art and graphical output shouldn't be mixed. – Martin Ender – 2017-02-04T16:22:56.157