Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import random

def functionToCreateArray():

"""This function is to generate a list of possible values"""

mainList = []
temporaryList = []

while True:

if len(mainList) == 3024:
break

x = str(random.randint(1,9))
temporaryList.append(x)

if len(temporaryList) == 4:
number = int(temporaryList[0] + temporaryList[1] + temporaryList[2] +
temporaryList[3])
checkerOfListHaveOnlyAllowNumbers =
(temporaryList.count(temporaryList[0]) == 1 and
temporaryList.count(temporaryList[1]) == 1 and
temporaryList.count(temporaryList[2]) == 1 and
temporaryList.count(temporaryList[3]) == 1)
temporaryList = []

if not int(number) in mainList and checkerOfListHaveOnlyAllowNumbers ==


True:
mainList.append(int(number))

return mainList

mainListOfNumbers = functionToCreateArray()

def main():

"""Function for finding the number that the user has guessed"""

global mainListOfNumbers
listWhisresoutsOfInput = []
listMainNew = []

while True:

number = random.randint(0, len(mainListOfNumbers))


number = mainListOfNumbers[number]

print('\n', number, sep='')


print(listWhisresoutsOfInput)

orders = int(input("Enter the number of orders :"))


disorder = int(input("Enter the number of orders :"))

listWhisresoutsOfInput.append([number, orders, disorder])

if orders == 4 and disorder == 0:


print("\n", "You won !!!", sep='')
break
if (orders + disorder) == 4 and len(mainListOfNumbers) == 3024:
for num in range(len(mainListOfNumbers)):

list_num = [str(j) for j in str(mainListOfNumbers[num])]

if str(number)[0] in list_num and str(number)[1] in list_num and


str(number)[2] in list_num and str(number)[3] in list_num:
listMainNew.append(mainListOfNumbers[num])

mainListOfNumbers = listMainNew
listMainNew = []

else :
mainListOfNumbers.remove(number)

if __name__ == "__main__":
main()

You might also like