Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Using Memory to Make Algorithm X Smarter
The following code block is identical to the last code block except for 3 lines added to override the _process_row_selection(self, row)
method and give Algorithm X the necessary memory to avoid duplicates.
Count the solutions to Mrs. Knuth - Part III Example Problem
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
# TECH.IO allows me to use this import statement to make my examples concise and easy
# to study. Unless your coding environment will let you create an AlgorithmX package,
# you will need to copy all of the AlgorithmXSolver code into your code.
from AlgorithmX import AlgorithmXSolver
class MrsKnuthPartIIISolver(AlgorithmXSolver):
def __init__(self, teacher_availability, students):
requirements = [('student scheduled', 'Drew', 1),
('student scheduled', 'Ella', 1),
('student scheduled', 'Ella', 2),
('student scheduled', 'Lola', 1)]
optional_requirements = [('slot filled', 'M', 8),
('slot filled', 'Tu', 8),
('slot filled', 'W', 8),
('slot filled', 'Th', 8),
('slot filled', 'F', 8),
('slot filled', 'F', 9),
('slot filled', 'F', 10),
('slot filled', 'F', 11),
('slot filled', 'F', 1),
('instrument on day', 'M', 'Trombone'),
('instrument on day', 'M', 'Drums'),
('instrument on day', 'M', 'Flute'),
('instrument on day', 'Tu', 'Trombone'),
('instrument on day', 'Tu', 'Drums'),
('instrument on day', 'Tu', 'Flute'),
('instrument on day', 'W', 'Trombone'),
('instrument on day', 'W', 'Drums'),
('instrument on day', 'W', 'Flute'),
('instrument on day', 'Th', 'Trombone'),
('instrument on day', 'Th', 'Drums'),
('instrument on day', 'Th', 'Flute'),
('instrument on day', 'F', 'Trombone'),
('instrument on day', 'F', 'Drums'),
('instrument on day', 'F', 'Flute'),
(('Drew', 'F', 10), ('Ella', 'F', 11)),
(('loud instrument', 'F', 8), ('loud instrument', 'F', 9)),
(('loud instrument', 'F', 9), ('loud instrument', 'F', 10)),
(('loud instrument', 'F', 10), ('loud instrument', 'F', 11))]
actions = dict()
action = ('place student', 'Drew', 'Trombone', 'F', 10, 1)
actions[action] = [('student scheduled', 'Drew', 1),
('slot filled', 'F', 10),
('instrument on day', 'F', 'Trombone'),
(('Drew', 'F', 10), ('Ella', 'F', 11)),
Enter to Rename, Shift+Enter to Preview
On to the puzzles!
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content