-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
40 lines (32 loc) · 1.21 KB
/
example.py
File metadata and controls
40 lines (32 loc) · 1.21 KB
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
from cluesolver import *
# for an example, this is puzzle S implemented
squares = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961]
S = Puzzle()
S.add_clue('1ac', 3)
S.add_clue('1dn', 3)
S.add_clue('2dn', 2)
S.add_clue('3ac', 2)
S.add_clue('4dn', 2)
S.add_clue('5ac', 3)
S.solve_order = ['4dn', '3ac', '2dn', '1ac', '1dn', '5ac']
S.clues['4dn'] = FixedClue([10, 15, 21, 28, 36, 45, 55, 66, 78, 91])
triangles = [21, 28, 36, 45, 55, 66, 78, 91, 105, 120,136, 153, 171, 190]
def clue_3ac(solution_set):
out = []
for triangle in triangles:
number = triangle - solution_set['4dn']
if number >= 10 and number < 100:
out.append(number)
return out
S.clues['3ac'] = TransformativeClue(clue_3ac)
def clue_2dn(solution_set):
return [reverse(solution_set['3ac'])]
S.clues['2dn'] = TransformativeClue(clue_2dn)
def clue_1dn(solution_set):
number = digit_sum(solution_set['1ac']) ** 2 + solution_set['3ac']
if number >= 100 and number < 1000: # solutions can be length-checked easily like this
return [number]
else:
return []
S.clues['1dn'] = TransformativeClue(clue_1dn)
S.solve()