@CallumIrving/

# num challenge

## No description

Files
• main.py
main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
```
```from random import *

#create number list and counter variable
a1 = [0,1,2,3,4,5,6,7,8]
b1 = [0,1,2,3,4,5,6,7]
c1 = [0,1,2,3,4,5,6]
d1 = [0,1,2,3,4,5]
e1 = [0,1,2,3,4]
f1 = [0,1,2,3]
g1 = [0,1,2]
h1 = [0,1]
counter = 0
listlist = []
#generate number funtion
def genNum():

a = randint(1,9)
while a%2==0:
a = randint(1,9)
b = randint(1, 4) * 2
while b == a:
b = randint(1, 4) * 2

c = randint(1, 9)
while c == a or c == b or c%2==0:
c = randint(1, 9)

d = randint(1, 4)*2
while d == a or d == b or d == c:
d = randint(1, 4)*2

e = randint(1, 9)
while e == a or e == b or e == c or e == d or e%2==0:
e = randint(1, 9)

f = randint(1, 4)*2
while f == a or f == b or f == c or f == d or f == e:
f = randint(1, 4)*2

g = randint(1, 9)
while g == a or g == b or g == c or g == d or g == e or g == f or g%2==0:
g = randint(1, 9)

h = randint(1, 4)*2
while h == a or h == b or h == c or h == d or h == e or h == f or h == g:
h = randint(1, 4)*2

i = randint(1, 9)
while i == a or i == b or i == c or i == d or i == e or i == f or i == g or i == h or i%2==0:
i = randint(1, 9)

j = 0
genNum.num = int(str(a)+str(b)+str(c)+str(d)+str(e)+str(f)+str(g)+str(h)+str(i)+str(j))

genNum.numString = str(genNum.num)
genNum.numString9 = [genNum.numString[i] for i in a1]
genNum.numString9 = int("".join(genNum.numString9))
genNum.numString8 = [genNum.numString[i] for i in b1]
genNum.numString8 = int("".join(genNum.numString8))
genNum.numString7 = [genNum.numString[i] for i in c1]
genNum.numString7 = int("".join(genNum.numString7))
genNum.numString6 = [genNum.numString[i] for i in d1]
genNum.numString6 = int("".join(genNum.numString6))
genNum.numString5 = [genNum.numString[i] for i in e1]
genNum.numString5 = int("".join(genNum.numString5))
genNum.numString4 = [genNum.numString[i] for i in f1]
genNum.numString4 = int("".join(genNum.numString4))
genNum.numString3 = [genNum.numString[i] for i in g1]
genNum.numString3 = int("".join(genNum.numString3))
genNum.numString2 = [genNum.numString[i] for i in h1]
genNum.numString2 = int("".join(genNum.numString2))

return;

#generate first number and assign characters
genNum()
while genNum.numString9 % 9 != 0 or genNum.numString8  % 8 != 0 or genNum.numString7 % 7 !=0 or genNum.numString6 % 6 != 0 or genNum.numString5 % 5 != 0 or genNum.numString4 % 4 != 0 or genNum.numString3 % 3 != 0 or genNum.numString2 % 2 != 0:

genNum()
if genNum.num not in listlist:
#add the number to list so it isn't used again and add another try to the counter
listlist.append(genNum.num)
print(genNum.num)
counter += 1

#display final number
print("The program found the number!")
print("The number is ",genNum.num)
print("It took " , counter , " tries")

```
Fetching token