Skip to content

Instantly share code, notes, and snippets.

@junho85
Last active October 3, 2018 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junho85/afa0cba6b879caba91cef5be0092ee20 to your computer and use it in GitHub Desktop.
Save junho85/afa0cba6b879caba91cef5be0092ee20 to your computer and use it in GitHub Desktop.
PS - 비밀지도 - 2018 KAKAO BLIND RECRUITMENT
# Python3
def solution(n, arr1, arr2):
answer = []
for idx in range(n):
result_arr = arr1[idx] | arr2[idx]
# answer.append(bin(result_arr)[2:].zfill(n).replace('1', '#').replace('0', ' '))
answer.append(format(result_arr, 'b').zfill(n).replace('1', '#').replace('0', ' '))
return answer
# test
# print(solution(5, [9, 20, 28, 18, 11], [30, 1, 21, 17, 28]))
print(solution(6, [46, 33, 33 ,22, 31, 50], [27 ,56, 19, 14, 14, 10]))
@junho85
Copy link
Author

junho85 commented Oct 3, 2018

숫자를 2진수 문제열로 바꾸는 두가지 방법

print(bin(5)[2:])
print(format(5, 'b'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment