# You are the Host of the Olympics!

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 of 3x - 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 of L 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 and 15 ≥ 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 , 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!

• Sandbox, for those who can view deleted posts. Commented Jun 20, 2017 at 14:30
• What should happen if x>=L?? Commented Jun 20, 2017 at 17:42
• @CraigR8806 The same algorithm. Just with more lanes than the length of the pool. I have a feeling that you have mistread the question... Commented Jun 20, 2017 at 17:45
• What about the case where L=10 and x=15? Would there not be more lanes than could be placed in the pool? I could be misunderstanding the intent Commented Jun 20, 2017 at 17:57
• @CraigR8806 The length has nothing to do with the lanes! You can test it yourself with one of the existing answers Commented Jun 20, 2017 at 17:59

# Charcoal, 32 bytes

ＮθＮη↓Ｅθ×η:  Ｂ⁺θ²⁺×³η¹↖←Ｂ⁺θ⁶⁺×³η³


Try it online!

-4 thanks to Neil.

AST:

Program
├Ｎ: Input Number
│└θ: Identifier θ
├Ｎ: Input Number
│└η: Identifier η
├Print
│├↓: Down
│└Ｅ: Map
│ ├θ: Identifier θ
│ └×: Product
│  ├η: Identifier η
│  └':  ': String ':  '
├Ｂ: Box
│├⁺: Sum
││├θ: Identifier θ
││└2: Number 2
│└⁺: Sum
│ ├×: Product
│ │├3: Number 3
│ │└η: Identifier η
│ └1: Number 1
├Move
│└↖: Up Left
├Move
│└←: Left
└Ｂ: Box
├⁺: Sum
│├θ: Identifier θ
│└6: Number 6
└⁺: Sum
├×: Product
│├3: Number 3
│└η: Identifier η
└3: Number 3

• wow Charcoal has got this challenge down :) Commented Jun 20, 2017 at 16:51
• You stayed true to your name - you have me outgolfed. Commented Jun 20, 2017 at 18:24
• As usual, explanation request. Commented Jun 20, 2017 at 22:04
• @CalculatorFeline Yeah, I don't have time to do all those explanations while I'm seeking something to outgolf...also you can check the AST using the -a command-line argument. Commented Jun 21, 2017 at 8:58
• why does -a raise error >_< Commented Jun 21, 2017 at 9:03

# Charcoal, 4039 37 bytes

ＮθＮηＢ⁺θ⁶⁺×³η³↘→Ｂ⁺θ²⁺×³η¹→Ｆ⁻η¹«Ｍ³↓Ｐ×:θ


Try it online!

I know Neil already has a Charcoal answer of around the same length, but I took a bit of a different approach so I figured I may as well also post mine.

## Explanation

ＮθＮηＢ⁺θ⁶⁺×³η³↘→Ｂ⁺θ²⁺×³η¹→Ｆ⁻η¹«Ｍ³↓Ｐ×:θ
ＮθＮη                                         take the two inputs as numbers in θ and η
Ｂ⁺θ⁶⁺×³η³                               draw a rectangle θ + 6 by 3η + 3
(characters default to |, - and +)
↘→                             move the cursor down one and right two
Ｂ⁺θ²⁺×³η¹                  draw a rectangle θ + 2 by 3η + 1
Ｆ⁻η¹«            for ι (unused) from 0 up until η - 1:
Ｍ³↓            move the cursor down by 3
Ｐ×:θ       print θ :s without moving the cursor
[implicit end of for]

• Explanation please. Commented Jun 20, 2017 at 22:04
• @CalculatorFeline Added. Commented Jun 20, 2017 at 22:16
• Huh, so the third parameter to Ｂ is optional? Nice, that saves me two bytes!
– Neil
Commented Jun 21, 2017 at 10:08

# Charcoal, 403836 31 bytes

Ａ⁺²ＮθＡ⁺¹×³ＮηＵＯθη:¶¶Ｂθη↖←Ｂ⁺⁴θ⁺²η


Try it online! Link is to verbose version of code. Explanation:

Ａ⁺²Ｎθ       Assign(Plus(2, InputNumber()), q);


Charcoal's drawing primitives use the overall character count including +s, however the input is just the number of -s, so we need to add 2 to obtain the width of the inner wall.

Ａ⁺¹×³Ｎη     Assign(Plus(1, Times(3, InputNumber())), h);


Calculate the height of the inner wall, again, inclusive of the bottom row, so three per lane plus one.

ＵＯθη:¶¶     Oblong(q, h, ":\n\n");


Draw the lanes. This is simply a rectangle filled with :s vertically separated by two blank lines (the pilcrows represent newline characters).

Ｂθη         Box(q, h);


The Rectangle command is exactly what we need to draw the inner wall. Edit: Box allows you to omit its third parameter, saving me 2 bytes.

↖           Move(:UpLeft);
←           Move(:Left);
Ｂ⁺⁴θ⁺²η     Box(Plus(4, q), Plus(2, h));


And again to draw the outer wall, except slightly wider and taller, and centred on the inner wall.

• Why are the links to Charcoal code at TIO never to the actual code? Commented Jun 20, 2017 at 14:57
• @JonathanAllan I link to the verbose code because it's more readable, plus I add the argument to generate the succinct code automatically for verification purposes.
– Neil
Commented Jun 20, 2017 at 14:59
• ...but how is 219 characters more readable than 40? :p Commented Jun 20, 2017 at 15:30
• I could have just looked harder and noticed this tip :) Commented Jun 20, 2017 at 17:04
• As usual, please explain. Commented Jun 20, 2017 at 17:35

# T-SQL, 284 281 bytes

DECLARE @ INT,@x INT,@S VARCHAR(MAX)='+--d--+b| +d+ |b'SELECT @=L,@x=x FROM t
P:SET @S+='| |s| |b| |s| |b| |c| |b'SET @x-=1IF @x>0GOTO P
PRINT REPLACE(REPLACE(REPLACE(REPLACE(LEFT(@S,LEN(@S)-6)+'+d+ |b+--d--+','d',REPLICATE('-',@)),'b',CHAR(13)),'s',SPACE(@)),'c',REPLICATE(':',@))


Input is taken from INT columns L and x in preexisting table t, per our allowed input methods.

Basically I'm creating a long string with letters representing the repeated characters (d=dashes, s=spaces, c=colons, b=line break), then REPLACE them all at the end with the appropriate fillers.

Formatted:

DECLARE @ INT,@x INT,@S VARCHAR(MAX)='+--d--+b| +d+ |b'
SELECT @=L,@x=x FROM t
P:
SET @S+='| |s| |b| |s| |b| |c| |b'
SET @x-=1
IF @x>0 GOTO P
PRINT REPLACE(REPLACE(REPLACE(REPLACE( LEFT(@S,LEN(@S)-6)+'+d+ |b+--d--+'
,'d',REPLICATE('-',@))
,'b',CHAR(13))
,'s',SPACE(@))
,'c',REPLICATE(':',@))


Inside the loop I append 2 rows of blanks and 1 row of colons, then at the end I chop off that divider row and append the pool border before performing the replaces.

EDIT: Saved 3 bytes by switching @ to the most-often used variable, and swapping initialization order.

# JavaScript (ES6), 137 124 bytes

Golfed it down a bit on my phone, more to follow.

x=>y=>+--0--+
| +0+ |
${((a=| |1| | )+a+| |2| | ).repeat(y-1)+a+a}| +0+ | +--0--+.replace(/\d/g,n=>"- :"[n].repeat(x))  ## Try it f= x=>y=>+--0--+ | +0+ |${((a=| |1| |
)+a+| |2| |
).repeat(y-1)+a+a}| +0+ |
+--0--+.replace(/\d/g,n=>"- :"[n].repeat(x))
oninput=_=>o.innerText=f(+i.value)(+j.value);o.innerText=f(i.value=50)(j.value=5)
input{font-family:sans-serif;margin:0 5px 0 0;width:50px;}
<label for=i>L: </label><input id=i type=number><label for=j>x: </label><input id=j type=number><pre id=o>

• I like this one because it's interactive :D Commented Jun 21, 2017 at 16:26
• @xDaizu, check out some of my other JS solutions, so ;) Commented Jun 21, 2017 at 17:33

# Python 2, 124120 117 bytes

-2 bytes thanks to Hyper Neutrino

l,x=input()
o='+--%s--+\n| +%s+ |\n'%(('-'*l,)*2)
print o+'| |%s| |\n'*(x*3-1)%((' '*l,' '*l,':'*l)*x)[:-1]+o[-2::-1]


Try it online!

• 122 bytes (your variable t is unnecessary) Commented Jun 20, 2017 at 15:59

# SOGL V0.12, 52 51 bytes

:┌* +1Ο;@*┐1ΟG∙⁴++⁰
b3*Ie4+⁰b3*He⁰32žbH∫3*2+4;e :*ž


Try it Here!
Not bad considering that 20 bytes of this is a rectangle function, which charcoal has a built-in for.

Explanation:

Rectangle function: (example: on stack 4, 2)
:                   duplicate the top of stack (X pos)      [4, 2, 2]
┌*                 get that many "-"es                     [4, 2, "--"]
+               push "+"                                [4, 2, "--", "+"]
1Ο             wrap the dashes in pluses               [4, 2, "+--+"]
;            get the duplicated X position           [4, "+--+", 2]
@*          get that many spaces                    [4, "+--+", "  "]
┐         push "|"                                [4, "+--+", "  ", "|"]
1Ο       wrap the spaces with "|"                [4, "+--+", "|  |"]
G      get the Y value ontop                   ["+--+", "|  |", 4]
∙     get an array with that many strings     ["+--+", ["|  |", "|  |", "|  |", "|  |"]]
⁴    duplicate the dashes wrapped in pluses  ["+--+", ["|  |", "|  |", "|  |", "|  |"], "+--+"]
++  add everything to one array             [["+--+", "|  |", "|  |", "|  |", "|  |", "+--+"]]
Main function: (example input: 2, 5)
b3*                              push variable B (input 1, Y length) multiplied by 3                     [6]
I                             increase it                                                             [7]
e4+                          push variable E (input 2, X length) + 4                                 [7, 9]
⁰                         execute the rectangle function [in X: E+4, Y: b*3+1]                    [["+---------+","|         |","|         |","|         |","|         |","|         |","|         |","|         |","+---------+"]]
b3*                      push variable B * 3                                                     [["+---------+",..,"+---------+"], 6]
H                     decrease it                                                             [["+---------+",..,"+---------+"], 5]
e                    push variable E                                                         [["+---------+",..,"+---------+"], 5, 5]
⁰                   execute the rectangle function [on X: E, Y: B*3-1]                      [["+---------+",..,"+---------+"], ["+-----+","|     |","|     |","|     |","|     |","|     |","+-----+"]]
32ž                at coordinates [3;2] (1-indexed) in the first rectangle put in the 2nd  [["+---------+",
"| +-----+ |",
"| |     | |",
"| |     | |",
"| |     | |",
"| |     | |",
"| |     | |",
"| +-----+ |",
"+---------+"]
bH∫             iterate over the numbers from 1 to B-1:                                 [[...], 1]
3*2+           push pop()*3+2                                                        [[...], 5]
4;         push 4 one below the stack                                            [[...], 4, 5]
e        push the variable E (X length)                                        [[...], 4, 5, 5]
:*     get that many colons                                                  [[...], 4, 5, ":::::"]
ž    insert [at coordinates [4; cIter*3+2] the colons]


# C# (.NET Core), 202 bytes

(L,x)=>{char p='+',n='\n',e=' ';string v="|",r="",s=p+new string('-',L+4)+p+n,q=v+e+p+new string('-',L)+p+e+v+n;r+=s+q;for(int i=0;i<3*x-1;)r+=v+e+v+new string(i++%3<2?e:':',L)+v+e+v+n;r+=q+s;return r;}


Try it online!

# Python 2, 128 126 bytes

L,x=input()
k='+'+'-'*(L+4)+'+\n| +'+'-'*L+'+ |\n'
f=lambda k:'| |'+k*L+'| |\n'
print k+f(':').join([f(' ')*2]*x)[:-1]+k[::-1]


Try it online!

-2 bytes thanks to @Mr.Xcoder

• 126 bytes Commented Jun 29, 2017 at 9:52
• @Mr.Xcoder Right, thanks, I don't know what I was thinking with those extra brackets :P Commented Jun 29, 2017 at 13:43

# PHP, 153 bytes

for(;$i-2<$z=3*$argv[2]+1;$i++)echo str_pad(strrev($r=["--+","+ |","| |"][!($b=$i>1&$i<$z)?$i&&$i<$z+1?1:0:2]),$argv[1]+3,"- :"[$b?$i%3!=1?1:2:0])."$r
";


Try it online!

# Python 2, 97 bytes

L,x=input()
for i in'01'+'223'*~-x+'2210':r=('+|||-   -+||'+L*'-- :')[int(i)::4];print r+r[2::-1]


Try it online!

# Python 2, 98 bytes

L,x=input()
s='+---| +-%s+-+---'%'|:'.join(['| '*5]*x)
while s:print s[:3]+s[3]*L+s[2::-1];s=s[4:]


Try it online!

# Charcoal, 36 bytes

ＮθＮηＦη«Ｍ³↑Ｐ×θ:»←Ｂ⁺θ²⁺×³η¹↖←Ｂ⁺θ⁶⁺×³η³


Try it online!

This is a more Charcoal-y algorithm than my other answer.

• Charcoal has officially taken over the whole challenge. 4/10 answers are in Charcoal... Commented Jun 20, 2017 at 18:41
• @Mr.Xcoder Well, it's a language specifically designed to golf ascii-art, so that's what you get for it. ;) Commented Jun 20, 2017 at 18:42
• Explanation request. Commented Jun 20, 2017 at 22:04
• @Mr.Xcoder And three of them are the same length too!
– Neil
Commented Jun 21, 2017 at 10:09

# C (gcc), 195 bytes

#define P printf
y;f(L,l){char s[L+1],t[L+1];memset(s,45,L);memset(t,58,L);t[L]=s[L]=0;P("+-%s-+\n|+%s+|\n",s,s);for(y=3*l;y-->1;y%3?P("||%*c||\n",L,32):P("||%s||\n",t));P("|+%s+|\n+-%s-+",s,s);}


Try it online!

# Perl 5, 124 + 1 (-a) = 125 bytes

say$o='+'.'-'x($l=pop@F),$t="----+ ",$i="| $o+ | ",$e=($d="| |").$"x$l.$d,$/,$e;say$d.':'x$l."$d$e
$e"for 2..$_;say$i,$o,$t  Try it online! # APL (Dyalog Unicode), 72 bytes {g' '∘,∘⌽∘⍉⍣4(g←{'+'@(⊂1 1)∘⌽∘⍉⍣4⊃(⍪∘⌽∘⍉)/'-|-|',⊂⍵})↑(¯1+3×⍵)⍺⍴⍺/' :'}  Try it online! A function that takes L on the left and x on the right. # Haskell, 111 bytes r=replicate a?b=a++b++reverse a l!x=unlines$map(?r l '-')["+--","| +"]?map("| |"?)(tail$concat$r x$r l<$>":  ")


Try it online!