You host the Olympic Games, and need to build a fantastic pool for the sake of the occasion, but the supervisors often change their mind regarding the dimensions, and need a quick way to rebuild it with the requested size!
Given two integers, L
and x
, your task is to build a swimming pool of length L
and x
lanes.
How is a pool built?
It contains an inner square, whose horizontal walls are made of
L
consecutive dashes(-
) , and whose vertical walls are made out of3x - 1
bars (|
). Additionally, 4+
signs lie in each corner. Let's have an example (L = 10, x = 2
):+----------+ | | | | | | | | | | +----------+
Each lane has a width of 2 vertical units. The inner square is filled with
x-1
lane separators, consisting ofL
horizontally consecutive:
symbols. After putting the lane separators, our pool should look like this:+----------+ | | | | |::::::::::| | | | | +----------+
A pool also contains a padding (an outer square), whose horizontal walls are (L+4)
-
s and whose vertical walls are (3x + 1)|
s, that surrounds the inner square:+--------------+ | +----------+ | | | | | | | | | | |::::::::::| | | | | | | | | | | +----------+ | +--------------+
And that's our olympic-sized** swimming pool!
Specs:
For design and functionality purposes, you are guaranteed that
100 ≥ L ≥ 10
and15 ≥ x ≥ 2
.The output must be exactly as shown. Outputting a "vertically-built"* pool is disallowed.
Trailing and leading spaces are allowed.
You may take input and provide output through any standard method.
Default Loopholes apply.
Examples / Test cases:
L = 20, x = 3 +------------------------+ | +--------------------+ | | | | | | | | | | |::::::::::::::::::::| | | | | | | | | | | |::::::::::::::::::::| | | | | | | | | | | +--------------------+ | +------------------------+ L = 50, x = 5: +------------------------------------------------------+ | +--------------------------------------------------+ | | | | | | | | | | |::::::::::::::::::::::::::::::::::::::::::::::::::| | | | | | | | | | | |::::::::::::::::::::::::::::::::::::::::::::::::::| | | | | | | | | | | |::::::::::::::::::::::::::::::::::::::::::::::::::| | | | | | | | | | | |::::::::::::::::::::::::::::::::::::::::::::::::::| | | | | | | | | | | +--------------------------------------------------+ | +------------------------------------------------------+ L = 10, x =15 +--------------+ | +----------+ | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | |::::::::::| | | | | | | | | | | +----------+ | +--------------+
This is code-golf, so the shortest code in bytes wins!
*The water could flow out if it is built vertically :P
**Yes, I am aware that the more the lanes are and the shorter the pool is, the less the drawing looks like a pool!
x>=L
?? \$\endgroup\$L=10
andx=15
? Would there not be more lanes than could be placed in the pool? I could be misunderstanding the intent \$\endgroup\$