Skip to content

Instantly share code, notes, and snippets.

@just-carlod
Created October 3, 2021 21:17
Show Gist options
  • Save just-carlod/63be0896293ba199a9af424c7a1c6c10 to your computer and use it in GitHub Desktop.
Save just-carlod/63be0896293ba199a9af424c7a1c6c10 to your computer and use it in GitHub Desktop.
binary1
#!/usr/bin/env python
# This gist has been written for my school purposes, so please don't be confused
n = int(input("Input a number: "))
binary = str(bin(n))[2:]
cur = ""
counter = 0
cur_counter = 0
for i in range(len(binary)):
if binary[i] == cur:
cur_counter += 1
else:
cur_counter = 1
if cur_counter > counter:
counter = cur_counter
cur = binary[i]
print("Counter:"+str(counter))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment