-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (38 loc) · 1.08 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Basic example of using dlxlib</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<pre id="messages" class="messages"></pre>
<script src="https://unpkg.com/dlxlib@2.0.0-alpha.2/dist/dlxlib.js"></script>
<script>
var messages = document.getElementById('messages')
function logMessage(message) {
messages.innerHTML = messages.innerHTML + message + '<br />'
}
var matrix = [
[1, 0, 0, 0],
[0, 1, 1, 0],
[1, 0, 0, 1],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]
]
function onStep(e) {
var message = 'step[' + e.stepIndex + ']: ' + JSON.stringify(e.partialSolution)
logMessage(message)
}
function onSolution(e) {
var message = 'solution[' + e.solutionIndex + ']: ' + JSON.stringify(e.solution)
logMessage(message)
}
var dlx = new dlxlib.Dlx()
dlx.on('step', onStep)
dlx.on('solution', onSolution)
dlx.solve(matrix)
</script>
</body>
</html>