[백준] #2290 LCD Test

2023. 6. 6. 00:50

https://www.acmicpc.net/problem/2290

 

2290번: LCD Test

첫째 줄에 두 개의 정수 s와 n이 들어온다. (1 ≤ s ≤ 10, 0 ≤ n ≤ 9,999,999,999)이다. n은 LCD 모니터에 나타내야 할 수 이며, s는 크기이다.

www.acmicpc.net

 

 

 

📕 설명 📕

 

7 segments 문제라고한다.

 

어려웠다.

 

🧑🏻‍💻 나의 풀이 🧑🏻‍💻

 

 

 

S, N = map(int, input().split())

N = str(N)
M = 2 * S + 3

ans = [[" "] * ((S + 2) * (len(N)) + (len(N) - 1)) for _ in range(M)]

st = 0
for i in N:
    if i == '1':
        st += S + 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '2':
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1

        for j in range(1, 1 + S):
            ans[j][st] = "|"
        st += 2
    elif i == '3':
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1

        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '4':
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[(M - 1) // 2][st] = "-"
            st += 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '5':
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '6':
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '7':
        st += 1
        for _ in range(S):
            ans[0][st] = "-"
            st += 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '8':
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    elif i == '9':
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[(M - 1) // 2][st], ans[M - 1][st] = "-", "-", "-"
            st += 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
    else:
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 1
        for _ in range(S):
            ans[0][st], ans[M - 1][st] = "-", "-"
            st += 1
        for j in range(1, 1 + S):
            ans[j][st] = "|"
        for j in range(2 + S, M - 1):
            ans[j][st] = "|"
        st += 2
for a in ans:
    print("".join(a))

'Programming > Algorithm' 카테고리의 다른 글

[백준] #1074 Z python  (0) 2023.06.08
[백준] #2688 줄어들지 않아 python  (0) 2023.06.07
[백준] #2502 떡 먹는 호랑이 python  (0) 2023.06.05
[백준] #1932 정수 삼각형 python  (0) 2023.06.02
[백준] #1080 행렬 python  (0) 2023.06.01

BELATED ARTICLES

more