## Task

Given `n` representing the number of floors build a beautiful multi-million dollar mansions like the ones in the example below:

```
     /\
    /  \
   /    \
  /______\  number of floors 3
  |      |
  |      |
  |______|

     /\
    /  \
   /____\
   |    |   2 floors
   |____|

     /\
    /__\    1 floor
    |__|
```

**Note:** whitespace should be preserved on both sides of the roof. Number of floors will go up to 30. There will be no tests with invalid input.

If you manage to complete it, you can try a harder version [here](https://www.codewars.com/kata/58360d112fb0ba255300008b).

Good luck!

Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code:
def my_crib(n):
	

Solutions:
def my_crib(n):
	roof = '\n'.join(('%s/%s\\%s' % (' ' * (n - i), ' ' * i * 2, ' ' * (n - i)) for i in range(n)))
	ceiling = '\n/%s\\\n' % ('_' * (n * 2))
	walls = '|%s|\n' % (' ' * (n * 2)) * (n - 1)
	floor = '|%s|' % ('_' * (n * 2))
	return roof + ceiling + walls + floor


def my_crib(n):
	roof = [('/' + ' ' * k + '\\').center(2 * n + 2) for k in range(0, 2 * n, 2)]
	ceiling = ['/' + '_' * 2 * n + '\\']
	walls = ['|' + ' ' * 2 * n + '|'] * (n - 1)
	floor = ['|' + '_' * 2 * n + '|']
	return '\n'.join(roof + ceiling + walls + floor)


def my_crib(n):
	return '\n'.join([' ' * (n - i) + '/' + ' ' * 2 * i + '\\' + ' ' * (n - i) for i in range(n)] + ['/' + '_' * 2 * n + '\\'] + ['|' + ' ' * 2 * n + '|'] * (n - 1) + ['|' + '_' * 2 * n + '|'])


def my_crib(n):
	(l, res) = (n + 1 << 1, [])
	res.extend(('/' + ' ' * (2 * i) + '\\' for i in range(n)))
	res.append('/' + '_' * (2 * n) + '\\')
	res.extend(('|' + ' ' * (l - 2) + '|' for _ in range(n - 1)))
	res.append('|' + '_' * (l - 2) + '|')
	return '\n'.join((s.center(l) for s in res))


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

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


import itertools

def my_crib(n):

	def format(chars, fill_width):
		return '{chars[0]}{chars[2]:{chars[1]}>{width}}'.format(chars=chars, width=fill_width + 1).center(2 * n + 2)
	return '\n'.join(itertools.chain((format('/ \\', 2 * i) for i in range(n)), (format('/_\\', 2 * n),), (format('| |', 2 * n) for _ in range(n - 1)), (format('|_|', 2 * n),)))


my_crib = lambda n: '\n'.join([('/' + [' ', '_'][i == n] * (i * 2) + '\\').center(n * 2 + 2, ' ') for i in range(n + 1)]) + '\n' + '\n'.join(['|' + [' ', '_'][i == n - 1] * (n * 2) + '|' for i in range(n)])


def my_crib(n):
	roof = '\n'.join(('{0}/{1}\\{0}'.format(' ' * (n - i), ' _'[n == i] * i * 2) for i in range(n + 1)))
	x = lambda a: '\n|' + a * n * 2 + '|'
	return roof + x(' ') * (n - 1) + x('_')


class House(object):
	(roofleft, roofright) = ('/', '\\')
	wall = '|'
	bottom = '_'

	def __init__(self, floors):
		self.floors = floors

	def __new__(cls, floors):
		a = super(House, cls).__new__(cls)
		a.__init__(floors)
		return str(a)

	@property
	def width(self):
		return self.floors * 2 + 2

	@property
	def height(self):
		return self.floors * 2 + 1

	@property
	def roofparts(self):
		return list(range(self.floors))

	@property
	def gutterparts(self):
		return list(range(max(self.roofparts) + 1, max(self.roofparts) + 2))

	@property
	def floorparts(self):
		return list(range(max(self.gutterparts) + 1, self.height - 1))

	@property
	def groundparts(self):
		return list(range(self.height - 1, self.height))

	def genpart(self, index):
		if index in self.roofparts:
			return self.genroof(index, outerfill=' ', innerfill=' ')
		if index in self.gutterparts:
			return self.genroof(index, outerfill='', innerfill='_')
		if index in self.floorparts:
			return self.genfloor(index, outerfill='', innerfill=' ')
		if index in self.groundparts:
			return self.genfloor(index, outerfill='', innerfill='_')

	def genroof(self, index, innerfill, outerfill):
		margin = '{:{outerfill}^{width}}'.format('', outerfill=outerfill, width=self.floors - index)
		roofpart = '{margin}{roofleft}{centerfill}{roofright}{margin}'.format(margin=margin, roofleft=self.roofleft, roofright=self.roofright, centerfill=innerfill * 2 * index)
		return roofpart

	def genfloor(self, index, innerfill, outerfill):
		margin = '{outerfill:{innerfill}^{width}}'.format(innerfill=innerfill, outerfill=outerfill, width=self.width)
		roofpart = '{wall}{centerfill}{wall}'.format(wall=self.wall, centerfill=innerfill * (self.width - 2))
		return roofpart

	def draw(self):
		lines = []
		for index in range(self.height):
			part = self.genpart(index)
			if not part:
				part = 'X' * self.width
			lines.append(part)
		return '\n'.join(lines)

	def bounding_box(self):
		lines = []
		for row in range(self.height):
			lines.append('X' * self.width)
		return '\n'.join(lines)

	@property
	def __name__(self):
		return [objname for (objname, oid) in list(globals().items()) if id(oid) == id(self)]

	def allnames(self):
		results = [n for (n, v) in list(globals().items()) if v is arg]
		return results[0] if len(results) is 1 else results if results else None

	def __repr__(self):
		return repr(self.draw())

	def __str__(self):
		return self.draw()

	def describe(self):
		return 'a bVectorian era {} story home called "{}" {{ signified as {}, identified as {} }}'.format(self.floors, self.__name__, repr(self), id(self))
my_crib = House

def testings():
	commonhouse = House(1)
	middleclasshouse = House(2)
	ritzyhouse = House(3)
	bigscaryhouse = House(4)
	cribs = [commonhouse, middleclasshouse, ritzyhouse, bigscaryhouse]
	for crib in cribs:
		print(crib)
		print(crib.draw())
		print(crib.roofparts, crib.gutterparts, crib.floorparts, crib.groundparts)