A **Seven Segment Display** is an electronic display device, used to display decimal or hexadecimal numerals. It involves seven led segments that are lit in specific combinations to represent a specific numeral. An example of each combination is shown below:

![seven segment display](https://upload.wikimedia.org/wikipedia/commons/9/97/7-segments_Indicator.gif)

For this Kata, you must accept an integer in the range `0 - 999999` and print it as a string (in decimal format), with each digit being represented as its own seven segment display (6x seven segment displays in total). Each of the individual led segments per display should be represented by three hashes `###`. Vertical bars `|` (ASCII 124) represent the edges of each display, with a single whitespace on either side between the edge and the area of the led segments. An example of the expected output is shown below:
```
segment_display(123456) = 
|       |  ###  |  ###  |       |  ###  |  ###  | 
|     # |     # |     # | #   # | #     | #     |
|     # |     # |     # | #   # | #     | #     |
|     # |     # |     # | #   # | #     | #     |
|       |  ###  |  ###  |  ###  |  ###  |  ###  |
|     # | #     |     # |     # |     # | #   # |
|     # | #     |     # |     # |     # | #   # |
|     # | #     |     # |     # |     # | #   # |
|       |  ###  |  ###  |       |  ###  |  ###  |
```
For clarity, the entire set of required combinations is provided below:

```
|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  |
| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |
| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |
| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |
|       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  |
| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |
| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |
| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |
|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  |
```
If the number is smaller than 6 digits, the result should be justified to the right, with the unused segments being blank (as they are not turned on). Refer to the sample test for an example.

**Note:** There should not be any trailing whitespace for any line.

Please rate and enjoy!

Difficulty: EASY
Starter code: def segment_display(num):
	

Solutions:
BASE = [r.split('|') for r in '  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  |       \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  |       \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       '.split('\n')]

def segment_display(n):
	digs = [int(d, 16) for d in f'{n:A>6}']
	return '\n'.join((f"|{'|'.join((BASE[x][d] for d in digs))}|" for x in range(len(BASE))))


from itertools import chain
lines = '\n|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  |       \n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |       \n|       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  |       \n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |       \n|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       \n'.lstrip().splitlines()

def digit_rotated(n):
	return [''.join((line[i] for line in lines)) for i in range(n * 8, (n + 1) * 8)]

def segment_display(n):
	digits = [int(c) for c in str(n)]
	if len(digits) < 6:
		digits = [-1] * (6 - len(digits)) + digits
	xs = (line for line in chain(*map(digit_rotated, digits), ['|||||||||']))
	return '\n'.join(map(''.join, zip(*xs)))


data = '\n  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # \n #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # \n       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # \n #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # \n  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  \n'
data = [line for line in data.split('\n') if line]
segments = [tuple(line.split('|')) for line in data]
(h, w) = (len(segments), len(segments[0][0]))

def segment_display(num):
	result = [[] for _ in range(h)]
	n = str(num)
	for _ in range(6 - len(n)):
		for i in range(h):
			result[i].append(' ' * w)
	for c in n:
		n = int(c)
		for i in range(h):
			result[i].append(segments[i][n])
	return '\n'.join(['|{}|'.format('|'.join(row)) for row in result])


displays = {'0': '012456', '1': '25', '2': '02346', '3': '02356', '4': '1235', '5': '01356', '6': '013456', '7': '025', '8': '0123456', '9': '012356', ' ': ''}
shape = ' 000 |1   2|1   2|1   2| 333 |4   5|4   5|4   5| 666 '.split('|')

def segment_display(n):
	s = str(n).rjust(6, ' ')
	return '\n'.join(('|' + '|'.join((' ' + (''.join((' #'[c in displays[d]] for c in shape[j])) + ' ') for d in s)) + '|' for j in range(9)))


def segment_display(num):
	segs = ' \n ### |     | ### | ### |     | ### | ### | ### | ### | ### \n#   #|    #|    #|    #|#   #|#    |#    |    #|#   #|#   #\n#   #|    #|    #|    #|#   #|#    |#    |    #|#   #|#   #\n#   #|    #|    #|    #|#   #|#    |#    |    #|#   #|#   #\n     |     | ### | ### | ### | ### | ### |     | ### | ### \n#   #|    #|#    |    #|    #|    #|#   #|    #|#   #|    #\n#   #|    #|#    |    #|    #|    #|#   #|    #|#   #|    #\n#   #|    #|#    |    #|    #|    #|#   #|    #|#   #|    #\n ### |     | ### | ### |     | ### | ### |     | ### | ### '
	numbers = {str(i): [] for i in range(10)}
	for s in segs.split('\n')[1:]:
		for (i, t) in enumerate(s.split('|')):
			numbers[str(i)].append(t)
	numbers[' '] = ['     '] * 9
	return '\n'.join(['| ' + ' | '.join([numbers[ch][y] for ch in f'{num:>6}']) + ' |' for y in range(9)])


s = '|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n|       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  |\n'.splitlines()
segment_display = lambda n: '\n'.join((''.join(i) + '|' for i in [['|       '] * (6 - len(str(n))) + [k[int(l)] for l in str(n)] for k in [[i[j:j + 8] for j in range(0, len(i), 8)] for i in s]]))


def segment_display(num):
	(fline, fl, fr, frl, empty) = (['  ###  '], [' #     '], ['     # '], [' #   # '], ['       '])
	codes = [empty * 9, fline + frl * 3 + empty + frl * 3 + fline, (empty + fr * 3) * 2 + empty, fline + fr * 3 + fline + fl * 3 + fline, (fline + fr * 3) * 2 + fline, empty + frl * 3 + fline + fr * 3 + empty, fline + fl * 3 + fline + fr * 3 + fline, fline + fl * 3 + fline + frl * 3 + fline, fline + (fr * 3 + empty) * 3 + empty, (fline + frl * 3) * 2 + fline, fline + frl * 3 + fline + fr * 3 + fline]
	result = ''
	for line in range(9):
		result += '|' + '|'.join([codes[0 if letter == ' ' else int(letter) + 1][line] for letter in str(num).rjust(6)]) + '|\n'
	return result[:-1]


all_num = '|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |  ###  |  ###  |  ###  |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n| #   # |     # |     # |     # | #   # | #     | #     |     # | #   # | #   # |\n|       |       |  ###  |  ###  |  ###  |  ###  |  ###  |       |  ###  |  ###  |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n| #   # |     # | #     |     # |     # |     # | #   # |     # | #   # |     # |\n|  ###  |       |  ###  |  ###  |       |  ###  |  ###  |       |  ###  |  ###  |'

def segment_display(num):
	all_num_list = all_num.split('\n')
	fish_list = []
	for val in all_num_list:
		fish_hold_list = []
		fish_hold = '' + '|       |' * (6 - len(str(num)))
		for num2 in str(num):
			num3 = int(num2)
			beg_col = num3 * 8
			end_col = beg_col + 9
			fish_hold += val[beg_col:end_col]
			fish_hold_list.append([fish_hold])
		fish_list.append(fish_hold)
	retval_list = []
	for val in fish_list:
		retval_list.append(val.replace('||', '|'))
	return '\n'.join(retval_list)


def segment_display(num):
	temp = str(num).rjust(6, '_')
	numbers = [[' ### ', '     ', ' ### ', ' ### ', '     ', ' ### ', ' ### ', ' ### ', ' ### ', ' ### '], ['#   #', '    #', '    #', '    #', '#   #', '#    ', '#    ', '    #', '#   #', '#   #'], ['#   #', '    #', '    #', '    #', '#   #', '#    ', '#    ', '    #', '#   #', '#   #'], ['#   #', '    #', '    #', '    #', '#   #', '#    ', '#    ', '    #', '#   #', '#   #'], ['     ', '     ', ' ### ', ' ### ', ' ### ', ' ### ', ' ### ', '     ', ' ### ', ' ### '], ['#   #', '    #', '#    ', '    #', '    #', '    #', '#   #', '    #', '#   #', '    #'], ['#   #', '    #', '#    ', '    #', '    #', '    #', '#   #', '    #', '#   #', '    #'], ['#   #', '    #', '#    ', '    #', '    #', '    #', '#   #', '    #', '#   #', '    #'], [' ### ', '     ', ' ### ', ' ### ', '     ', ' ### ', ' ### ', '     ', ' ### ', ' ### ']]
	res = []
	for i in range(len(numbers)):
		string = []
		for (j, num) in enumerate(temp):
			string.append(' ' * 5) if num == '_' else string.append(numbers[i][int(num)])
		res.append('| ' + ' | '.join(string) + ' |')
	return '\n'.join(res)