-
Notifications
You must be signed in to change notification settings - Fork 4
/
hint.py
68 lines (55 loc) · 1.32 KB
/
hint.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
import random
def hintGen(answer):
hint = []
len_ans= len(answer)
if 0 <= len_ans <= 4:
h_min = 1
h_max = 2
elif 4 <= len_ans <= 8:
h_min = 2
h_max = 3
elif 8 <= len_ans <= 12:
h_min = 3
h_max = 5
elif 12 <= len_ans <= 16:
h_min = 4
h_max = 8
else:
h_min = 5
h_max = 12
_hint = ''
nums = [x for x in range(len(answer))]
random.shuffle(nums)
for x in range(len(answer)):
if answer[x] != ' ':
_hint += '_ '
else:
_hint += ' '
hint.append(_hint)
_hint = ''
for x in range(len(answer)):
if x in nums[:h_min]:
if answer[x] != ' ':
_hint += answer[x] + ' '
else:
_hint += ' '
else:
if answer[x] != ' ':
_hint += '_ '
else:
_hint += ' '
hint.append(_hint)
_hint = ''
for x in range(len(answer)):
if x in nums[:h_max]:
if answer[x] != ' ':
_hint += answer[x] + ' '
else:
_hint += ' '
else:
if answer[x] != ' ':
_hint += '_ '
else:
_hint += ' '
hint.append(_hint)
return hint