Skip to content

Instantly share code, notes, and snippets.

@akionsight
Last active January 4, 2023 09:03
Show Gist options
  • Save akionsight/f4a531fbc89b55e18b2814f32e4da058 to your computer and use it in GitHub Desktop.
Save akionsight/f4a531fbc89b55e18b2814f32e4da058 to your computer and use it in GitHub Desktop.
the most accurate software-based 8 ball ever, play it
import random
import hashlib
import time
def main():
choices = ['As I see it, yes.', 'Ask again later.', ' Better not tell you now.', ' Cannot predict now.', 'Concentrate and ask again.', 'Don’t count on it.', 'It is certain.', ' It is decidedly so.', ' Most likely.', 'My reply is no.', 'My sources say no.', 'Outlook not so good.', ' Outlook good.', 'Reply hazy, try again.', 'Signs point to yes.', ' Very doubtful.', ' Without a doubt.', ' Yes.', 'Yes – definitely.', 'You may rely on it.']
question = input('Enter your question: ')
hash_question_object = hashlib.sha256(question.encode())
hex_digest = hash_question_object.hexdigest()
random.seed(hashlib.sha512(hex_digest.encode()).hexdigest() + str(time.time()))
random.shuffle(choices)
print(random.choice(choices))
if __name__ == '__main__':
main()
Copy link

ghost commented Mar 28, 2021

Noice! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment