Input:
1
X
X
X
X XX XXXXXX X X X
X XX XXXXXX X X X
XXX X XX XXXXXX X X X
XXX X XX XXXXXX X X X
Output:
X.
X..
X...
X.... XX. XXXXXX. X.X.X.
X..... XX.. XXXXXX.. X.X.X..
XXX. X......XX... XXXXXX... X.X.X...
XXX.. X......XX....XXXXXX.... X.X.X....
Input:
2
XX
XX
XX
XX
XX
XX XX
XX XX
XX XX
XX XX
Output:
.XX
..XX
...XX
....XX
.....XX
..XX..XX
...XX..XX
....XX..XX
.....XX..XX
Specification:
- You must take as input
- A flag signifying whether the light is coming from the top left or top right. This can be
1
or2
,-1
or1
,0
or65536
, or whatever is convenient for you, as long as both flags are integers. - Rows composed of either
X
or, all of the same length in characters (i.e. padded with
)
- All
X
s will either be on the last row or have anX
under them (meaning no floating buildings)
- All
- A flag signifying whether the light is coming from the top left or top right. This can be
- You must output the rows (buildings) with shadows added. This is done with the following procedure:
- If the light is coming from the top left, draw a right triangle of
.
s with the same height and width as the height of the building, starting from one space past its right edge and going rightwards. - Otherwise, if it's from the top right, do the same thing but start from one space past its left edge and pointing left.
- Remember, do not alter
X
s by changing them to.
s; leave them as they are. - There will always be "room" for your shadows, i.e. if there's a 3-space tall building at the end there will be at least 3 spaces of padding after it.
- If the light is coming from the top left, draw a right triangle of
- This is code-golf, so the shortest code in bytes will win!
{}
and{-1*}
as flag values? \$\endgroup\$potato
andwhile(1){}
. As quoted in the question, "whatever is convenient." \$\endgroup\$Regex.Replace
which I can't work around... do I have two problems now? \$\endgroup\$