Last active
September 18, 2019 07:03
-
-
Save anderseknert/b3823d152928f1c1d6cf8173a238567c to your computer and use it in GitHub Desktop.
Generate random swedish personal ID
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
import datetime, random | |
ssid = "{}{:02d}{}".format(*[x for x in ['{:%y%m%d}'.format(datetime.datetime(1970, 1, 1) + datetime.timedelta(days=random.randint(-30, 30) * 365 + random.randint(0, 365))), random.randint(0, 99), random.randint(0, 9)]]) | |
print("{}{}".format(ssid, (10 - (sum(map(lambda x: x%10 + int(x/10), map(lambda x,y: x*y, map(int, ssid), [2,1]*4 + [2]))) % 10)) % 10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment