# Draw an ASCII house

This is a window:

---
| |
---

Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room.

|  ---  |
|  | |  |
|  ---  |

Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it.

---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Now, just add a roof. Put a slash as far left as possible, and a backslash as far right as possible, and we have this:

/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Then move the slash up one and right one. Move the backslash up one and left one:

/     \
/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Repeat until the two slashes meet, then add an asterisk where they meet:

*
/ \
/   \
/     \
/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

And you're done! This is a 1x1 house. a 2x2 house would look like this:

*
/ \
/   \
/     \
/       \
/         \
/           \
/             \
/               \
-----------------
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
|-------|-------|
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
-----------------

and a 3x2 house:

*
/ \
/   \
/     \
/       \
/         \
/           \
/             \
/               \
/                 \
/                   \
/                     \
/                       \
-------------------------
|       |       |       |
|  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |
|       |       |       |
|-------|-------|-------|
|       |       |       |
|  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |
|       |       |       |
-------------------------

# The challenge

You must write a full program that takes two integers, x and y, and prints a house that is X rooms wide and Y rooms tall. Your program should be able to handle houses up to 10x10. IO can be in any reasonable format. Trailing spaces on each line are allowed, and one trailing newline is allowed.

# Vim 122, 89 Keystrokes

"aDJ"bD9i-<esc>Y2pVr <C-v>jr|$.Y4p3l<C-v>jljlr-jR| |<esc>{l<C-v>}d@apjdG@bp}Vr-{YPVr r/$r\qqYPllxx|P@qq@qddr*

Try it online!

I've improved my vim-golfing skills significantly since I posted this answer, so I decided to go back and write this whole thing from scratch. Saved thirty-three bytes in the process!

Input is assumed to be on two separate lines, so that the buffer looks like this before you start typing:

3
4

I had a very detailed explanation, but I don't feel like writing it all over again from the beginning... >_< Check out the revision history if you still want to see it.

## Python 3.6 (pre-release), 221210 203 bytes

x,y=eval(input())
w=8*x+1;p='-'*w+'\n'
for v in['*',*[f'/{" "*i}\\'for i in range(1,w-1,2)],p+p.join([''.join(f'{"".join([f"|{(a*3)[:3]:^7}"]*x)}|\n'for a in(*' -','| |',*'- '))]*y)+p]:print(v.center(w))

Reads 2 integers (separated by comma) from stdin, prints the house to stdout.

x, y = eval(input())
w = 8 * x + 1 # total width (in characters)
p = '-' * w + '\n' # floors
for v in [
'*', # asterisk
*[f'/{" "*i}\\' for i in range(1, w-1, 2)], # roof
p + p.join([''.join(f'{"".join([f"|{(a*3)[:3]:^7}"]*x)}|\n' for a in (*' -','| |',*'- '))]*y) + p # rooms
]:
print(v.center(w))
• Which 3.6.0a0 feature/s does this use? Just f'{name}' string formatting?
– cat
Mar 2 '16 at 17:49
• @tac: only f-strings, yes Mar 2 '16 at 17:50
• How did you install 3.6? I've been eagerly waiting for f-strings, but couldn't figure out how to install it myself (then again, Cygwin support isn't great) Mar 3 '16 at 12:18
• @Sp3000: I built it from source Mar 3 '16 at 12:53
• @Sp3000 Python 3.3+ won't build on Cygwin.
– user45941
Mar 4 '16 at 22:05

## Python 2, 190 181 bytes

w,h=input();W=w*4
for i in range(~W,h*6+1):print['-'[i%(h*6):]*(W-~W)or['  %s  '%' -|-  - -  -|- '[~i%6::5],'-'*7][i%6<1].join('|'*-~w),' '*~i+['/%*c'%(w*8-~i*2,92),'*'][W<-i]][i<0]

Pretty sure there's much to golf, especially the windows, but here's something for now. Input width and height comma-separated, e.g. 1,2.

Quick and rough explanation:

*          <--- i = ~W = -w*4 - 1.    <---\
/ \         <--\ i = -W = -w*4             | Preceding spaces
/   \           |                           | are calculated
/     \          |                           | the same way
/       \      <--/ i = -1                <---/
/--->    ---------      <--- i = 0
|        |       |      <--\ i = 1                 <---\
Check       |  ---  |         |                           | Calculate inner string
i%(h*6)     |  | |  |         |                           | and use to join '|'s
is zero     |  ---  |         |                           | (ditto with |-------|)
|        |       |      <--/ i = h*6 - 1           <---/
\--->    ---------      <--- i = h*6

^       ^
\-------/

W-~W = w*8 + 1

# JavaScript (ES6), 292270238215 200 bytes

Thanks @Neil for helping trim this down!

a=>b=>[(p=(c,d=' ')=>d.repeat(c))(m=4*a)+'*',...[...Array(m)].map((c,i)=>p(--m)+/${p(i*2+1)}\\‌),y=p(8*a+1,'-')].join +p(b, +[x=p(a,'|'+p(7)),w=p(a,'| --- '),p(a,'| | | '),w,x,y].join| ) Call as: F(a)(b) Builds the roof, then assembles the core house with layered string repeats. • When I saw your answer I pondered whether you should have used join|\n and now I wish I had commented at the time. It would have been a good excuse to add to my partial comment suggesting you use 9*a at some point, which I never submitted because it was too short. – Neil Mar 3 '16 at 0:34 • Your formula 4*a-1 looks incorrect, I think it should be 4*a, this would incidentally save you 4 bytes. – Neil Mar 3 '16 at 0:44 • m-i-1 becomes --m. 9*a-a becomes 8*a. – Neil Mar 3 '16 at 0:46 • Now, you're not actually using any templates in your strings, and you could have done  *\n${[...Array(m)].map(...).join\n}\n  but you can go one better and join the string before and after at the same time: a=>b=>(p=(c,d=' ')=>d.repeat(c),[p(m=4*a)+*,...[...Array(m)].map((c,i)=>p(--m)+'/'+p(i*2+1)+'\\'),y=p(8*a+1,'-')].join\n+p(b,\n+[x=p(a,'| '),w=p(a,'| --- '),p(a,'| | | '),w,x,y].join|\n))
– Neil
Mar 3 '16 at 0:48

Try it Online!

A. Mess.