-
2개 이하로 다른 비트코딩 테스트/Level 2 2021. 7. 20. 10:22반응형
https://programmers.co.kr/learn/courses/30/lessons/77885
solution = lambda numbers: [(num + 1) if (num % 2 == 0) else (num + (num ^ (num + 1) + 1) / 4 + 0.5) for num in numbers]
def solution(numbers): return [(num + 1) if (num % 2 == 0) else (num + (num ^ (num + 1) + 1) / 4 + 0.5) for num in numbers]
def solution(numbers): answer = [] for num in numbers: if num % 2 == 0: answer.append(num + 1) else: answer.append(int(num + (num ^ (num + 1) + 1) / 4 + 0.5)) return answer
def solution(numbers): answer = [] for num in numbers: if num & 1 == 0: answer.append(num + 1) else: answer.append(int(num + (num ^ (num + 1) + 1) / 4 + 0.5)) return answer
반응형