~2023/Codility 썸네일형 리스트형 Codility - CyclicRotation # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A, K): # write your code in Python 3.6 # step 1 - take input A,K # already succeed # step 2 - create new array arr_ = list(range(len(A))) # step 3 - take iteration to solve the prob for i in range(len(A)): arr_[(i+K)%len(A)] = A[i] return arr_ pass 더보기 Codility - Binary Gap def solution(N): # write your code in Python 3.6 binary_num = bin(N) arr_ = [] for i in range(2,len(binary_num)): if binary_num[i] == '1': arr_.append(i) arr2_ = [] for i in range(0,len(arr_)): if i != len(arr_) - 1: tmp = arr_[i+1] - arr_[i] tmp = tmp - 1 arr2_.append(tmp) if len(arr2_) == 0: return 0 else: return max(arr2_) pass 더보기 이전 1 2 3 4 5 다음