Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import *
- from os import *
- from time import *
- from random import *
- """ Python program to Katie and Paul's three dice in a glass box solution! """
- """ Problem by standupmaths """
- """ by Calvin Pash """
- def roll():
- print ('Rolling in 1 second')
- sleep(1)
- global d1
- d1 = randint(1,6) ## roll
- global d2
- d2 = randint(1,6)
- global d3
- d3 = randint(1,6)
- print ('Original values are: ' + str(d1) + ', ' + str(d2) + ', ' + str(d3))
- print ()
- global output1
- global even
- global evenlist
- global evend1
- global evend2
- global evend3
- global even1
- global output2
- global evenlist
- global dicelist
- global val36
- global edge
- d1 = d1
- output1= int(d1) + int(d2) + int(d3)
- output1=output1 % 6 ## modulus of sum of dice
- if output1 == 0:
- output1 = 6
- print('Mod of dice values is ' + str(output1))
- if output1 % 2 == 0: ## checks if even
- even = 1 ## this will come in use later
- d1 = 7 - d1
- d2 = 7 - d2
- d3 = 7 - d3
- else:
- even = 0
- evenlist = [] ## this is to check if there are two different even numbers
- if d1 % 2 == 0:
- evend1 = 1 ## created these values to reference if dice values are even
- else:
- evend1 = 0
- evenlist.insert(1, 1)
- if d2 % 2 == 0:
- evend2 = 1
- else:
- evend1 = 0
- evenlist.insert(1, 2)
- if d3 % 2 == 0:
- evend3 = 1
- else:
- evend1 = 0
- evenlist.insert(1, 3)
- if d2 == d1 or d2 == d3 or d1 == d3: ## this is just to make it different even #s
- evenlist.insert(1, 4)
- if len(evenlist) > 1: ## if more than one violation it knows that there arent 2 even #s
- print ('There are not more than 2 different even numbers')
- even1 = 0 ## this is the second even check
- else:
- print ('There are two different even numbers')
- even1 = 1
- if even1 == 1:
- if evenlist.count(1) > 0: ## checks if first dice is odd
- if even == 1:
- output2 = 7 - d1
- output() ## this is my other function and outputs the final values
- else:
- output2 = d1
- output()
- if evenlist.count(2) > 0: ## same for second
- if even == 1:
- output2 = 7 - d2
- output()
- else:
- output2 = d2
- output()
- if evenlist.count(3) > 0: ## and third
- if even == 1:
- output2 = 7 - d3
- output()
- else:
- output2 = d3
- output()
- if even1 == 0:
- if output1 == 3 or output1 == 6: ## This is for the 2nd to last item on the chart
- print ('D1 equals 3 or 6')
- val36 = 1
- dicelist = [d1, d2, d3] ## this is how I am checking the edge
- dicelist.sort() ## so that I can check it once
- if dicelist[0] == 2 and dicelist[1] == 2 and dicelist[2] == 5:
- print ('Edge is true')
- edge = 1
- if even == 1:
- output2 = 5
- output()
- else:
- output1 = 2
- output()
- else:
- print ('Edge is false')
- edge = 0
- set(dicelist) ## this deletes all duplicates in list
- output2 = int(len(dicelist)) * 2
- """ above multiplies length of unique values by two since all
- duplicate values are deleted """
- if even == 1:
- output2 = 7 - output2
- output()
- else:
- val36 = 0
- def output(): ## output function I was talking about
- print ()
- print ('Dice 1: ' + str(output1))
- print ('Dice 2: ' + str(output2))
- cont = 'y'
- while cont == 'y':
- print ('Three dice to Two dice roll')
- ## system('cls')
- roll()
- if even == 1: ## All of this is to display a completed flowchart
- if even1 == 1:
- print('http://picpaste.com/dice11.png')
- else:
- if val36 == 1:
- if edge == 1:
- print('http://picpaste.com/dice1011.png')
- else:
- print('http://picpaste.com/dice1010.png')
- else:
- print('http://picpaste.com/dice100.png')
- else:
- if even1 == 1:
- print('http://picpaste.com/dice01.png')
- else:
- if val36 == 1:
- if edge == 1:
- print('http://picpaste.com/dice0011.png')
- else:
- print('http://picpaste.com/dice0010.png')
- else:
- print('http://picpaste.com/dice000.png')
- cont = input('Restart? (y/n)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement