https://softeer.ai/practice/info.do?idx=1&eid=624&sw_prbl_sbms_sn=134941
Softeer
연습문제를 담을 Set을 선택해주세요. 취소 확인
softeer.ai
해당 디지털보드에 번호를 부여한다
세그먼트 표시라 하는데, 뭐 이건 변수 이름이니 필요없고
0~9일때까지 디지털 보드가 어떻게 변환되어야 하는지 일차원 리스트를 이용하여 segment란 리스트에 저장
그 뒤 하나씩 뽑아서 틀린게 있는지 없는지 확인 후, 틀린게 있다면 틀린갯수를 카운트 해준다.
import sys
input = sys.stdin.readline
t = int(input())
type0 = [1,1,1,0,1,1,1]
type1 = [0,0,1,0,0,1,0]
type2 = [1,0,1,1,1,0,1]
type3 = [1,0,1,1,0,1,1]
type4 = [0,1,1,1,0,1,0]
type5 = [1,1,0,1,0,1,1]
type6 = [1,1,0,1,1,1,1]
type7 = [1,1,1,0,0,1,0]
type8 = [1,1,1,1,1,1,1]
type9 = [1,1,1,1,0,1,1]
emp = [0,0,0,0,0,0,0]
segment = [type0] + [type1] + [type2] + [type3] + [type4] + [type5] + [type6] + [type7] + [type8] + [type9] + [emp]
for tc in range(t):
a,b = list(map(str,input().split()))
if len(a) <=5:
a = [10]*(5-len(a))+list(a)
if len(b) <=5:
b = [10]*(5-len(b)) + list(b)
cnt = 0
for i in range(5):
if segment[int(b[i])] != segment[int(a[i])]:
for j in range(7):
if segment[int(b[i])][j] != segment[int(a[i])][j]:
cnt+=1
print(cnt)
'Algorithm > softeer' 카테고리의 다른 글
[파이썬]softeer: 비밀 메뉴 (0) | 2023.01.26 |
---|---|
[파이썬]softeer: 바이러스 (0) | 2023.01.25 |
[파이썬]softeer: 회의실 예약 (0) | 2023.01.24 |
[파이썬]softeer: 금고털이 (1) | 2023.01.23 |
댓글