Last active
February 29, 2020 08:50
-
-
Save supersonictw/6138aa0d13db944089d8c7642a9f49eb to your computer and use it in GitHub Desktop.
To verify black hole number by python
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 python3 | |
# (c) 2020 SuperSonic (https://github.com/supersonictw) | |
import random | |
def int_split(num: int): | |
return [i for i in str(num)] | |
def int_com(num: list): | |
s = "" | |
for i in num: | |
s += i | |
return int(s) | |
for time in range(20): | |
t = 0 | |
x = 0 | |
y = 0 | |
timeout = 0 | |
sample = random.randint(1000, 9999) | |
sample_ = int_split(sample) | |
print("> {}".format(sample)) | |
while t != 6174: | |
x = sample_.copy() | |
x.sort(reverse=False) | |
y = sample_.copy() | |
y.sort(reverse=True) | |
t = int_com(y)-int_com(x) | |
timeout += 1 | |
if timeout is 10: | |
break | |
elif t is not 6174: | |
sample_ = int_split(t) | |
if timeout is not 10: | |
print("[success] time:{}".format(timeout)) | |
else: | |
print("[timeout]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment