-
Notifications
You must be signed in to change notification settings - Fork 0
/
19.py
89 lines (80 loc) · 1.67 KB
/
19.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
#алгоритм такой же, как и в с++, но не понимаю, почему не работает(согласен, код ужасный)???
import random
f = 0
a = 1
check = True
n = int(input())
allpassword = []
password = str(input())
notall=""
size_password = len(password)
notpassword =[size_password]
for i in range (size_password):
notpassword.append(0)
alll = ""
for i in range (1,size_password+1):
a*=i
for i in range (size_password):
for j in range (n):
notall += password[i]
notpassword[i] = notall
notall =""
allpassword =[a]
if(size_password<n):
for j in range (a):
check = True
for i in range (n):
x = random.randint(0,size_password-1)
alll += password[x]
allpassword.append(alll)
alll = ""
if (j>0):
for i in range (j):
if (allpassword[i]==allpassword[j]):
check = False
allpassword[j] =""
break
else:
continue
for h in range (size_password):
if (allpassword[j]==notpassword[h]):
check = False
allpassword[j]=""
break
else:
continue
if(check):
print(allpassword[j])
else:
j=j-1
continue
else:
for j in range (a):
check = True
for i in range (n):
x = random.randint(0,size_password-1)
alll+=password[x]
allpassword[j]=alll
for h in range(j):
if (allpassword[j]==notpassword[h]):
check =False
allpassword[j] =""
alll=""
break
else:
continue
if (check == False):
break
if (check == True):
for t in range (j):
if (allpassword[t]==allpassword[j]):
check = False
allpassword[j]=""
alll = ""
break
if (check == True):
print(allpassword[j]," ", end="")
alll = ""
else:
j-=1
continue