# -*- coding: utf-8 -*-
"""
Created on Tue Jan 9 09:07:50 2018
@author: vmahout
"""
import random
import math
def Hazard():
x = math.trunc(9*random.random())+1
x = x*10 + math.trunc(9*random.random())+1
x = x*10 + math.trunc(9*random.random())+1
x = x*10 + math.trunc(9*random.random())+1
return(x)
def Tri(V1,V2,V3,V4) :
a1 = max(V1,V2)
a2 = min(V1,V2)
a3 = max(V3,V4)
a4 = min(V3,V4)
b1 = max(a1,a3)
b2 = max(a2,a4)
b3 = min(a1,a3)
b4 = min(a2,a4)
return(b1,max(b2,b3),min(b2,b3),b4)
def Separe(X):
y4 = math.trunc(X/1000)
y3 = math.trunc((X - y4*1000)/100)
y2 = math.trunc((X -y3*100 -y4*1000)/10)
y1 = math.trunc((X-y2*10 - y3*100- y4*1000))
return(y4,y3,y2,y1)
def Saisie() :
Z = int(input('Donnez un nombre : ' ))
Resu = -1
if ((Z <= 9999) and (Z > 0) ):
a,b,c,d = Separe(Z)
if ((a != 0) and (b != 0) and (c!= 0) and (d != 0)):
Resu = Z
return (Resu)
def Diff(Val1,Val2) :
f1,f2,f3,f4 = Separe(Val1)
g1,g2,g3,g4 = Separe(Val2)
r1,r2,r3,r4 = Tri(f1-g1,f2-g2,f3-g3,f4-g4)
return(r1,r2,r3,r4)
def Tour(nb,Devine):
print('\n Tour ',nb)
Victoire = 0
Val = Saisie();
if (Val !=-1):
d1,d2,d3,d4 = Diff(Devine,Val)
print('\n\t\tLes différences sont ', d1,d2,d3,d4)
if ((d1 == 0) and (d2 == 0) and (d3 == 0) and (d4 == 0) ):
Victoire = 1
else:
print('\n Le nombre saisi n\'est pas correct')
return(Victoire)
############################################################################