Skip to content

Instantly share code, notes, and snippets.

View 9terz's full-sized avatar
🏠
Working from home

9terz 9terz

🏠
Working from home
View GitHub Profile
@9terz
9terz / bingap.py
Created September 22, 2018 18:13
bingap
def bingap(num):
binary = str(bin(num))[2:]
print("binary is {}".format(binary))
numlist = binary.split('1')
return len(max(numlist, key=len))
print(bingap(6666))
@9terz
9terz / onetimeswap.py
Created September 23, 2018 14:33
One time swap
def isAbleToOneTimeSwapSort(arr):
print(arr)
sortArray = sorted(arr)
count = 0
for i in range(0, len(sortArray)):
sortedOne = sortArray[i]
oldOne = arr[i]
if sortedOne != oldOne:
count += 1
if count <= 2: