Created
October 3, 2021 21:17
-
-
Save just-carlod/63be0896293ba199a9af424c7a1c6c10 to your computer and use it in GitHub Desktop.
binary1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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