[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] [1์ฐจ] ๋น๋ฐ์ง๋ / Python
๐ Problem Solving/Programmers
import sys
input = sys.stdin.readline
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
def solution(n, arr1, arr2):
answer = []
for i in range(len(arr1)):
temp1 = bin(arr1[i] | arr2[i])[2:]
temp2 = "0" * (n - len(temp1)) + temp1
temp2 = temp2.replace("0", " ")
temp2 = temp2.replace("1", "#")
answer.append(temp2)
return answer
print(solution(n, arr1, arr2))
ํด์ค
or ๋ ผ๋ฆฌ ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ๋ค. ๋ ์ค ํ๋๊ฐ 1์ด๋ฉด 1์ด๊ธฐ ๋๋ฌธ์ ์ง๋๋ฅผ ๊ฒน์ณค์ ๋์ ๊ฒฐ๊ณผ๋ฅผ ์ ์ ์๋ค.
ํด๋น ๊ฒฐ๊ณผ๋ฅผ bin์ ์ด์ฉํด 2์ง์๋ก ๋ณํํ๊ณ , ์ 0์ ๊ฐ์๋ n-len(temp1)๋งํผ ์ถ๊ฐ์ํจ๋ค.
์ด๋ ๊ฒ ์ป์ ๋ฐ์ดํฐ์์ 1์ '#'์ผ๋ก, 0์ ' '์ผ๋ก replace์ํจ ํ, answer ๋ฆฌ์คํธ์ ์ถ๊ฐ์ํจ๋ค.
'๐ Problem Solving > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค-Lv2] ๋ ๋งต๊ฒ / Python (0) | 2021.06.02 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค-Lv2] ๊ธฐ๋ฅ๊ฐ๋ฐ (0) | 2021.06.02 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ / Python (0) | 2021.06.02 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] 3์ง๋ฒ ๋ค์ง๊ธฐ / Python (0) | 2021.06.02 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ์์ฐ / Python (0) | 2021.06.02 |