Skip to content

Instantly share code, notes, and snippets.

@Titowisk
Last active December 20, 2018 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Titowisk/e95cb9dec5a3e827c59855fadc8a5f51 to your computer and use it in GitHub Desktop.
Save Titowisk/e95cb9dec5a3e827c59855fadc8a5f51 to your computer and use it in GitHub Desktop.
Sequencial Error Calculator
import random
number_of_tries = 1000
number_of_sequencial_errors = 4
error_values = [7,8,9,10] # the condition of unwanted number
percentage = (10 - len(error_values))/10 * 100
previous = False # save the previous generated number
condition = 0 # verifies when the error happens 3 times
count = 0 # counts the number of times the error happens 3 times in a row
total = 0
# test_list = []
for n in range(number_of_tries):
rolled_number = random.randint(1, 10)
# test_list.append(rolled_number)
# if previous matches the unwanted values
if (rolled_number in error_values):
total += 1
condition += 1
else:
condition = 0
if condition == 4:
count += 1
print(39*"-")
print("Percentage: {0}%".format(percentage))
print("Number of times rolled {0}".format(number_of_tries))
print("Number of errors {0} times in a row: {1}".format(number_of_sequencial_errors, count))
print("Number of errors in total: {0}".format(total))
# print("Test: {0}".format(test_list))
print(39*"-")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment