Skip to content

Instantly share code, notes, and snippets.

@liamstrilchuk
Created September 15, 2020 15:23
Show Gist options
  • Save liamstrilchuk/bd870eb6ed912299a639d3fa8aced9db to your computer and use it in GitHub Desktop.
Save liamstrilchuk/bd870eb6ed912299a639d3fa8aced9db to your computer and use it in GitHub Desktop.
lol italia lol
import sys, praw, time, math
def main():
N = 350
LINE TO DEFINE REDDIT WITH MY PASSWORD GOES HERE
sub = reddit.subreddit("u_iwillgetitalia")
target = base36decode(sys.argv[1])
for post in reddit.subreddit("all").stream.submissions():
print(abs(base36decode(post.id) - target + N), post.id)
if abs(base36decode(post.id) - target + N) < 3:
for i in range(150):
sub.submit("italy", f"aiming for {target}")
# time.sleep(0.1)
break
def base36encode(number):
alphabet, base36 = ['0123456789abcdefghijklmnopqrstuvwxyz', '']
while number:
number, i = divmod(number, 36)
base36 = alphabet[i] + base36
return base36 or alphabet[0]
def base36decode(number):
return int(number, 36)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment