-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchsticks.py
More file actions
48 lines (43 loc) · 914 Bytes
/
matchsticks.py
File metadata and controls
48 lines (43 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
def smallest(n):
strNum = ''
while n > 11:
if n == 17: break
strNum += '8'
n -= 7
if n == 17:
strNum += '002'
if n == 11:
strNum += '02'
if n == 10:
strNum += '22'
if n == 9:
strNum += '81'
if n == 8:
strNum += '01'
elif n == 7:
strNum += '8'
elif n == 6:
strNum += '6'
elif n == 5:
strNum += '2'
elif n == 4:
strNum += '4'
elif n == 3:
strNum += '7'
elif n == 2:
strNum += '1'
return strNum
test = int(input())
for t in range(test):
n = int(input())
# print(str(n)+" ", end = ' ')
print(smallest(n)[::-1], end=' ')
if n%2:
print('7', end='')
for i in range(1, (n-1)//2):
print('1', end='')
else:
for i in range(n//2):
print('1', end='')
print()