Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check(my_list):
- return my_list[0] == my_list[1]
- total = 0
- correct = 0
- def generate(my_list, a, b, c):
- if a == 0 and b == 0 and c == 0:
- global total, correct
- total += 1
- if check(my_list):
- correct += 1
- return
- if a > 0:
- generate(my_list + [0], a - 1, b, c)
- if b > 0:
- generate(my_list + [1], a, b - 1, c)
- if c > 0:
- generate(my_list + [2], a, b, c - 1)
- generate([], 2, 2, 2)
- print('total =', total)
- print('correct =', correct)
- print('accuracy =', correct / total)
Advertisement
Add Comment
Please, Sign In to add comment