https://school.programmers.co.kr/learn/courses/30/lessons/17681
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
def solution(n, arr1, arr2):
arr1_map = []
arr2_map = []
result = []
# 2진수
def binary(num):
b = ''
while num > 0:
b = str(num%2) + b
num //= 2
if len(b) < n:
for _ in range(n - len(b)):
b = '0' + b
return b
# 구현부
for e in arr1:
arr1_map.append(binary(e))
for e in arr2:
arr2_map.append(binary(e))
for a, b in zip(arr1_map, arr2_map):
temp = ''
for i in range(n):
if a[i] == '0' and b[i] == '0':
temp += " "
else:
temp += "#"
result.append(temp)
return result
728x90
반응형
'🔻Algorithm > Programmers' 카테고리의 다른 글
[Programmers] 프로그래머스 튜플 Python (0) | 2024.05.16 |
---|---|
[Programmers] 프로그래머스 다트 게임 Python (0) | 2024.05.16 |
[Programmers] 프로그래머스 실패율 Python (0) | 2024.05.14 |
[Programmers] 프로그래머스 캐시 Python (0) | 2024.05.12 |
[Programmers] 프로그래머스 귤 고르기 Python (0) | 2024.05.12 |