숫자를 문자로
n = str(n)
문자를 리스트로
nums = list(str(n))
한글을 사용하려면
상단에
# -*- coding: utf-8 -*-
를 삽입해 주어야 합니다.
전체 소스
# -*- coding: utf-8 -*-
file = 'p004.LCD.in'
f = open(file, 'r')
lcd = []
lcd.append([1,1,1,0,1,1,1])
lcd.append([0,0,1,0,0,1,0])
lcd.append([1,0,1,1,1,0,1])
lcd.append([1,0,1,1,0,1,1])
lcd.append([0,1,1,1,0,1,0])
lcd.append([1,1,0,1,0,1,1])
lcd.append([1,1,0,1,1,1,1])
lcd.append([1,0,1,0,0,1,0])
lcd.append([1,1,1,1,1,1,1])
lcd.append([1,1,1,1,0,1,1])
while True:
s, n = [int(x) for x in f.readline().split()]
if n == 0 and n == 0 :
break
nums = list(str(n))
print nums
# 상단
p = " "
for num in nums:
num = int(num)
if lcd[num][0] == 1:
p += "-" * s
else:
p += " " * s
p += " " * 3 # 공백추가
print p
# 상단 좌우
for i in xrange(s):
p = ""
for num in nums:
num = int(num)
# 좌상
if lcd[num][1] == 1:
p += "|"
else:
p += " "
p += " " * s# 공백추가
# 우상
if lcd[num][2] == 1:
p += "|"
else:
p += " "
p += " "
print p
# 중간
p = " "
for num in nums:
num = int(num)
if lcd[num][3] == 1:
p += "-" * s
else:
p += " " * s
p += " " * 3 # 공백추가
print p
# 하단 좌우
for i in xrange(s):
p = ""
for num in nums:
num = int(num)
# 좌상
if lcd[num][4] == 1:
p += "|"
else:
p += " "
p += " " * s# 공백추가
# 우상
if lcd[num][5] == 1:
p += "|"
else:
p += " "
p += " "
print p
# 하단
p = " "
for num in nums:
num = int(num)
if lcd[num][6] == 1:
p += "-" * s
else:
p += " " * s
p += " " * 3 # 공백추가
print p
""" INPUT
2 12345
3 67890
0 0
"""
""" OUTPUT
['1', '2', '3', '4', '5']
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
['6', '7', '8', '9', '0']
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
"""
'Programming > Python' 카테고리의 다른 글
| [python] 인터프리터 (Interperter) - 나머지 연산 (0) | 2015.10.31 |
|---|---|
| [python] 그래픽 편집기(Graphical Editor) - 재귀호출 (0) | 2015.10.31 |
| [python] 여행(The Trip) - round (0) | 2015.10.28 |
| [python] 문자열 찾기 (0) | 2015.10.27 |
| [python] 지뢰 찾기 (Minesweeper) - 이중 배열 (0) | 2015.10.27 |
댓글