## MTV Cribs is back!

![](https://s-media-cache-ak0.pinimg.com/236x/1b/cf/f4/1bcff4f4621644461103576e40bde4ed.jpg)

_If you haven't solved it already I recommend trying [this kata](https://www.codewars.com/kata/5834a44e44ff289b5a000075) first._

## Task

Given `n` representing the number of floors build a penthouse like this:

```
        ___
       /___\                
      /_____\
      |  _  |     1 floor
      |_|_|_|
      
       _____
      /_____\
     /_______\
    /_________\             
   /___________\
   |           |
   |    ___    |     2 floors
   |   |   |   |
   |___|___|___|
 
      _______
     /_______\
    /_________\
   /___________\
  /_____________\
 /_______________\
/_________________\
|                 |         3 floors
|                 |
|      _____      |
|     |     |     |
|     |     |     |
|_____|_____|_____|

```

**Note:** whitespace should be preserved on both sides of the roof. No invalid input tests.

Good luck!

Difficulty: introductory

Starter code:

def my_crib(n):
	

Solutions:
def my_crib(n):
    wide = 4 + 3 + 6 * (n - 1)
    door = 2 + n - 1
    roof = 3 + 2 * (n - 1)
    r = '{0}{1}{0}\n'.format(' ' * (wide // 2 - n), '_' * (3 + 2 * (n - 1)))
    for i in range(1, roof):
        r += '{0}/{1}\\{0}\n'.format(' ' * (wide // 2 - n - i), '_' * (3 + 2 * (n - 1) + 2 * (i -1)))
    for i in range(roof - 1 - door):
        r += '|{}|\n'.format(' ' * (wide - 2))
    r += '|{0}{1}{0}|\n'.format(' ' * ((wide - 1) // 3), '_' * (1 + 2 * (n - 1)))
    for i in range(1, door - 1):            
        r += '|{0}|{0}|{0}|\n'.format(' ' * ((wide - 2) // 3))
    return r + '|{0}|{0}|{0}|'.format('_' * ((wide - 2) // 3))



def my_crib(n):
    r, ws, wu = ['_' *(2*n + 1)], ' ' * (2*n - 1), '_' * (2*n - 1)
    r += ['/' + '_' *(2*(n + i) + 1) + '\\' for i in range(2*n)]
    r += ['|' + ws + ' ' + ws + ' ' + ws + '|' for i in range(n - 1)]
    r += ['|' + ws + ' ' + wu + ' ' + ws + '|']
    r += ['|' + ws + '|' + ws + '|' + ws + '|' for i in range(n - 1)]
    r += ['|' + wu + '|' + wu + '|' + wu + '|']
    return '\n'.join(l.center(n*6 + 1) for l in r)

def my_crib(n):
    # n -- integer number greater than one representing the number of floors
    n *= 2
    # Build the house from top to bottom
    # Roof and Ceiling
    mansion = ["{}{}{}".format(" " * n, "_" * (n+1), " " * n)]
    mansion.extend("{0}/{1}\\{0}".format(" " * (n-i-1), "_" * (n+1+2*i)) for i in range(n))
    # Walls and  Door
    mansion.extend("|{}|".format(" " * (3*n-1)) for i in range(n // 2 - 1))
    mansion.append("|{0}{1}{0}|".format(" " * n, "_" * (n-1)))
    mansion.extend("|{0}|{0}|{0}|".format(" " * (n-1)) for i in range(n // 2 - 1))
    # Floor with the Door
    mansion.append("|{0}|{0}|{0}|".format("_" * (n-1)))
    return "\n".join(mansion)


def my_crib(n):
    mult = (2*n) - 1
    top_roof = "_" * ((n*2)+1)
    top_roof = top_roof.center((n*6)+1, ' ')
    resulty = ''
    resulty += top_roof + '\n'
    for i in range(n*2):
        medium_roof = '/' + '_' * int((2*(i + n) + 1)) + '\\'
        medium_roof = medium_roof.center((n*6)+1, ' ')
        resulty += medium_roof + '\n'
    for j in range(n - 1):
        top_house = '|' + ' ' * ((n*6) - 1) + '|'
        resulty += top_house + '\n'
    upper_door = '|' + ' '*(n*2) + '_'*mult + ' '*(n*2) + '|'
    resulty += upper_door + '\n'
    for h in range(n - 1):
        medium_house = '|' + ' '*mult + '|' + ' '*mult + '|' + ' '*mult + '|'
        resulty += medium_house + '\n'
    basement = '|' + '_'*mult + '|' + '_'*mult + '|' + '_'*mult + '|'
    resulty += basement
    return resulty

def my_crib(n):
    crib = [f"{mult(n*2)}{mult(n*2+1, '_')}{mult(n*2)}"]
    crib.extend(f"{mult(n*2-i-1)}/{mult((n+i)*2+1, '_')}\\{mult(n*2-i-1)}" for i in range(n*2))
    crib.extend(f"|{mult(n*6-1)}|" for _ in range(n-1))
    crib.append(f"|{mult(n*2)}{mult(n*2-1, '_')}{mult(n*2)}|")
    crib.extend(f"|{mult(n*2-1)}|{mult(n*2-1)}|{mult(n*2-1)}|" for _ in range(n-1))
    crib.append(f"|{mult(n*2-1, '_')}|{mult(n*2-1, '_')}|{mult(n*2-1, '_')}|")
    return "\n".join(crib)


def mult(n, char=" "):
    return char * n

def my_crib(n):
    
    line    = lambda n,l,m,r: f'{ l }{ m*n }{ r }'.center(W)
    topDoor = lambda: f'|{ ( "_"*half_1 ).center(W-2) }|'
    door    = lambda b: ( b*half_1 ).join('||||')
    
    W, H, half_1 = 6*n+1, 4*n+1, 2*n-1
    
    return '\n'.join( line(2*(n+i)-1, *('/_\\' if i else '___')) if i<=2*n else
                      line(W-2, *'| |')                          if i< 3*n else
                      topDoor()                                  if i==3*n else
                      door('_' if i==4*n else ' ')               for i in range(H) )

def my_crib(n):
    req, space = 3 + (2 * (n - 1)), 3 + (2 * ((n + (n * 2)) - 1))
    door = (space - 2) - (n * 4)
    roof =[[('_'*req).center(space,' ')] +
           [('/'+'_'*(req+(2*i))+'\\').center(space,' ') for i in range(n*2)] + 
           ['|'+' '*(space-2)+'|' for i in range(n-1)] +
           ['|'+(' '*n*2)+('_'*door)+(' '*n*2)+'|'] +
           ['|'+' '*(n*2-1)+'|'+' '*door+'|'+' '*(n*2-1)+'|' for i in range(n-1)] + 
           ['|'+'_'*(n*2-1)+'|'+'_'*door+'|'+'_'*(n*2-1)+'|']]
    return "\n".join(roof[0])

def my_crib(n):
    #build roof
    crib_string = ' '*(2*n)+'_'*(2*n+1)+' '*(2*n)+'\n'
    for i in range(1,2*n+1):
        crib_string += ' '*(2*n-i)+'/'+'_'*(2*n+2*i-1)+'\\'+' '*(2*n-i)+'\n'
        
    #build floors
    for i in range(n-1):
        crib_string += '|'+' '*(6*n-1)+'|\n'
    crib_string += '|'+' '*(2*n)+'_'*(2*n-1)+' '*(2*n)+'|\n'
    for i in range(n-1):
        crib_string += '|'+' '*(2*n-1)+'|'+' '*(2*n-1)+'|'+' '*(2*n-1)+'|\n'
    crib_string += '|'+'_'*(2*n-1)+'|'+'_'*(2*n-1)+'|'+'_'*(2*n-1)+'|'
    
    return(crib_string)

def my_crib(n):
    temp = []
    temp.append(' '*(2*n) + '_'*(2*n+1) + ' '*(2*n))
    for i in range(2*n):
        strr = '\n' + (2*n-i-1)*' ' + '/' + (2*n+1 +2*i) * '_' + '\\'
        if i!=2*n and i!=2*n-1:
            strr += ' '*(2*n-i-1)
        
        temp.append(strr)
    
    strr2 = '\n|'+(n*6-1)*' ' + '|'
    temp.append((n-1)*strr2)
    strr3 = '\n|' + 2*n*' ' + (2*n-1)*'_' + 2*n*' ' + '|'
    temp.append(strr3)
    strr4 = '\n|' + (2*n-1)*' ' + '|' + (2*n-1)*' '+ '|' + (2*n-1)*' '+'|'
    temp.append((n-1)*strr4)
    temp.append('\n|')
    strr5 = (2*n-1)*'_'+'|'
    temp.append(3*strr5)
    temp2 = ''.join(temp)

    return temp2