Engineering Note

비밀지도 본문

Problem Solving/Programmers

비밀지도

Software Engineer Kim 2021. 7. 17. 00:55

it 취업을 위한 알고리즘 문제 풀이

문제

코드

def tenTobinary(number):
    binary = []
    temp = number

    while temp:
        binary.insert(0, temp % 2)

        temp //= 2

    res = "".join(map(str,binary))
    return res


def solution(n, arr1, arr2):
    answer = []

    for i in range(len(arr1)):
        binary1 = tenTobinary(arr1[i])
        binary2 = tenTobinary(arr2[i])

        while len(binary1) < n :
            binary1 = "0" + binary1

        while len(binary2) < n :
            binary2 = "0" + binary2

        secretMap = ""

        for j in range(n):
            if binary1[j] == "0" and binary2[j] == "0":
                secretMap += " "
            else:
                secretMap += "#"
        else:
            answer.append(secretMap)


    return answer

문제해결방법

'Problem Solving > Programmers' 카테고리의 다른 글

[Programmers] 모의고사  (0) 2021.11.02
스킬 체크 테스트 Level.1  (0) 2021.07.17
네트워크  (0) 2021.06.27
단어변환  (0) 2021.06.27
타겟넘버  (0) 2021.06.15
Comments