-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
419 lines (376 loc) · 15.8 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
---
layout: null
---
<html>
<head>
<title>Interactive Sudoku Solver</title>
<meta name="description" content="Fast interactive Sudoku solver. Supports many variants and up to 16x16 grids.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="{{ 'img/favicon.png' | relative_url }}">
<link rel="canonical" href="https://sigh.github.io/Interactive-Sudoku-Solver/" />
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2SQH4BL89R"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-2SQH4BL89R');
</script>
<style type="text/css" media="screen">
.hide-until-load {
display: none !important;
}
</style>
<script defer src="{{ '/data/example_puzzles.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer src="{{ '/js/util.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer src="{{ '/js/sudoku_builder.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer src="{{ '/js/display.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer
src="{{ '/js/constraint_displays.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer
src="{{ '/js/solution_controller.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script defer src="{{ '/js/render_page.js?v=' | append: site.github.build_revision | relative_url }}"></script>
<script>
var VERSION_PARAM = '?v=' + ('{{ site.github.build_revision }}' || Math.random());
window.addEventListener('load', () => initPage());
</script>
<link rel="stylesheet" href="{{ 'css/style.css?v=' | append: site.github.build_revision | relative_url }}">
</head>
<body>
<h1>Interactive Sudoku Solver (ISS)</h1>
<div id="instruction-panel">
<div>
<div class="description">
<p>
To set a value, select a cell and type a number.
</p>
<p>
To add a line or region constraint, select and drag; or shift-click.
</p>
<p>
To add a Little Killer
<span class="tooltip" data-text="Values along diagonal must add to the given sum. Values may repeat.">
</span>
constraint, select a diagonal arrow outside the grid.
</p>
<p>
To add other outside clue constraints, select a row or column arrow outside the grid.
</p>
</div>
</div>
<div>
<span class="description">OR</span>
<span id="example-select-container">
<select id="example-select">
<option>-- Load an example --</option>
</select>
<a style="display:none">(Source)</a>
</span>
</div>
<div>
<span class="description">OR</span>
<form id="freeform-constraint-input">
<span id="freeform-constraint-text-container">
<textarea id="freeform-constraint-text" name="freeform-input" rows="3"></textarea>
<button type="submit" title="Load from text">Load from text</button>
</span>
</form>
</div>
</div>
<hr>
<div id="debug-container" class="hidden">
<div id="debug-panel">
<label>
Log level
<select id="debug-log-level">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</label>
<label>
<input type="checkbox" id="backtrack-heatmap-checkbox">
Backtrack heatmap
</label>
<div>
<input list="debug-puzzles" id="debug-puzzle-input" placeholder="Load a puzzle">
<datalist id="debug-puzzles"></datalist>
</div>
<div id="debug-puzzle-src"></div>
<input type="checkbox" id="debug-cell-id" class="debug-checkbox">
<label for="debug-cell-id">Show cell id</label>
<input type="checkbox" id="debug-cell-index" class="debug-checkbox">
<label for="debug-cell-index">Show cell index</label>
<button id="close-debug-button" class="danger-button" title="Close debug">Close debug</button>
</div>
<div id="debug-counters"></div>
<div id="debug-logs"></div>
</div>
<div id="sudoku-container">
<div>
<div id="sudoku-grid-and-state">
<div id="display-panel">
<div id="solve-mode-input-container">
<select id="solve-mode-input">
<option value="all-possibilities" checked>All possibilities</option>
<option value="solutions">Solutions</option>
<option value="count-solutions">Count solutions</option>
<option value="step-by-step">Step-by-step</option>
<option value="validate-layout">Validate layout</option>
</select>
<div id="solve-mode-description" class="description"></div>
</div>
<div id="state-output"></div>
<div>
<div id="progress-container">
<progress value=0 id="solve-progress"></progress>
<span id="solve-status"></span>
<span id="solve-percentage"></span>
</div>
<div id="state-buttons">
<button id="chart-button" title="Show stats charts" class="image-button" disabled>
<img src="img/chart-48.png" alt="Chart">
</button>
<button id="download-solutions-button" title="Download solutions" class="image-button" disabled>
<img src="img/download-48.png" alt="Download">
</button>
<button id="copy-solution-button" title="Copy solution to clipboard" class="image-button" disabled>
<img src="img/copy-48.png" alt="Copy">
</button>
</div>
</div>
</div>
<div id="sudoku-grid-with-controls">
<div id="sudoku-grid">
<input id="fake-input" inputmode="numeric" type="text" value="x">
</div>
<div id="grid-control-buttons" class="control-panel">
<div id="solution-control-panel">
<div id="solution-iteration-state"></div>
<div id="solution-control-buttons">
<button id="solution-start" class="icon-button" title="start (s)">«</button>
<button id="solution-back" class="icon-button" title="previous (p)">‹</button>
<button id="solution-forward" class="icon-button" title="next (n)">›</button>
<button id="solution-end" class="icon-button" title="end">»</button>
</div>
</div>
<div class="control-panel">
<div class="switch">
<label>
<input id="auto-solve-input" type="checkbox" checked>
<span></span>
</label>
Auto-solve
</div>
<button id="solve-button" class="big-button" title="solve">Solve</button>
<button id="stop-solver" class="big-button danger-button" title="abort">Abort</button>
</div>
</div>
</div>
</div>
</div>
<div>
<div id="error-panel" class="error"></div>
<div id="stats-container">
<div id="stats-header">
<h2>Stats by runtime</h2>
<button id="chart-close-button" class="danger-button" title="Close chart view">✖</button>
</div>
</div>
<div id="constraint-panel-container">
<div>
<h1>Constraints</h1>
<div class="control-panel">
<button id="copy-constraints-button" title="Copy constraint to clipboard" class="image-button">
<img src="img/copy-48.png" alt="Copy constraint">
</button>
<button id="clear-constraints-button" class="danger-button" title="Clear all constraints">Clear All</button>
<button id="undo-button" class="icon-button" title="undo" disabled>⤺</button>
<button id="redo-button" class="icon-button" title="redo" disabled
style="transform:rotateY(180deg)">⤺</button>
</div>
</div>
<div class="two-column hide-until-load">
<div>
<form id="multi-value-cell-input">
<fieldset tabindex="0" class="constraint-panel" disabled>
<h2>Set multiple values</h2>
<div></div>
</fieldset>
</form>
<form id="multi-cell-constraint-input">
<fieldset tabindex="0" class="constraint-panel">
<h2>Lines & Sets</h2>
<div id="multi-cell-constraint-body">
<span class="description">
Select cells by dragging or shift-clicking.
</span>
<div>
<select id="multi-cell-constraint-select" name="constraint-type">
</select>
</div>
<div id="multi-cell-constraint-description" class="description">
</div>
<div id="multi-cell-constraint-loop-container">
<input type="checkbox" name="is-loop" id="multi-cell-constraint-loop-input"></input>
<label for="multi-cell-constraint-loop-input">Loop</label>
</div>
<div>
<div id="multi-cell-constraint-value-container"></div>
<button type="submit" name="add-constraint" title="Add constraint" disabled>
Add
</button>
</div>
</div>
</fieldset>
</form>
</div>
<div>
<div id="shape-container" class="constraint-panel">
<h2>
Shape
<select id="shape-select"></select>
<span class="tooltip" data-text="
Change the grid shape.
Box regions are made as close to square as possible.
Prime numbered grid sizes have no boxes.">
</span>
</h2>
</h2>
</div>
<div class="constraint-panel" id="global-constraints-container">
<h2>Global constraints</h2>
<div id="global-constraint-checkboxes"></div>
</div>
</div>
</div>
<div id="layout-constraint-container" class="constraint-panel hide-until-load">
<h2>Layout constraints</h2>
<div class="two-column">
<div id="layout-constraint-checkboxes"></div>
<div id="jigsaw-container">
<div>
<button type="submit" id="add-jigsaw-button" title="Add Piece">
Add Jigsaw Piece
</button>
<span class="tooltip"
data-text="Values inside the jigsaw piece can't repeat. Pieces cannot overlap and must contain a cell for each different value (i.e. 9 cells for a 9x9 grid)."></span>
</div>
<div id="jigsaw-chip-view" class="chip-view"></div>
</div>
</div>
</div>
<form id="custom-binary-input" class="hide-until-load">
<fieldset tabindex=" 0" class="constraint-panel" disabled>
<h2>Custom binary constraints</h2>
<div>
<div>
<div class="description">
<p>
Create a constraint between two cells by providing a custom
JavaScript function.
</p>
<p>
The function takes the two cell values as input and should
return true or false to indicate if the pair of values is
valid.
</p>
<p>
Example: <code>a < b</code> will emulate a thermometer
constraint.
</p>
</div>
<div>
Name:
<input type="text" name="name" placeholder="optional" maxlength="20" columns="20">
</div>
<div>
Chain handling
<span class="tooltip" data-text="
Select how to handle chains of more than two cells. e.g. for
a chain of cells [A, B, C] 'Consecutive pairs' will create
constraints on [A, B] and [B, C] while 'All pairs' will create
constraints on [A, B], [A, C], [B, A], [B, C], [C, A]
and [C, B].">
</span>:
<select name="chain-mode">
<option value="Binary">Consecutive pairs</option>
<option value="BinaryX">All pairs</option>
</select>
</div>
<div>
<div id="custom-binary-input-function">
Constraint: <code>(a,b) =></code>
<textarea rows="3" name="function"></textarea>
</div>
<div id="custom-binary-input-function-error" class="error"></div>
</div>
<div>
<button type="submit" title="Add constraint" name="add-constraint">
Add
</button>
</div>
</div>
</div>
</fieldset>
</form>
<div class="hide-until-load">
<form id="outside-clue-input">
<fieldset tabindex="0" class="constraint-panel" disabled>
<h2>Outside clues</h2>
<div id="outside-clue-input-body">
<div class="description">
Select a row, column or diagonal arrow outside the grid.
</div>
<input type="hidden" name="id">
<div class="outside-arrow-clue-types"></div>
<div>
<input type="number" name="value" min=0 placeholder="value">
<button type="submit" title="Set constraint">Set</button>
<button type="button" id="outside-arrow-clear" class="danger-button"
title="Clear constraint">Clear</button>
</div>
</div>
</fieldset>
</form>
</div>
<div class="hide-until-load">
<form id="composite-constraint-input">
<fieldset tabindex="0" class="constraint-panel">
<h2>Composite constraints (experimental)</h2>
<div>
<div>
<span class="description">
Select a composite constraint by clicking on its chip to
add constraints to it. Panels which allow constraints to be
added to the composite will be highlighted in yellow.
</span>
<button type="button" name="add-or" title="Add 'Or'">
+ Or
</button>
<button type="button" name="add-and" title="Add 'And'">
+ And
</button>
</div>
<div id="composite-chip-view" class="chip-view"></div>
</div>
</fieldset>
</form>
</div>
<div id="ordinary-chip-view" class="chip-view"></div>
</div>
</div>
</div>
<footer>
Solver runs fastest on Chrome.
<a href="https://github.com/sigh/Interactive-Sudoku-Solver/issues">
[File a bug]</a>
<a href="javascript:loadDebug()">[Load debug mode]</a>
<br>
Code at
<a href="https://github.com/sigh/Interactive-Sudoku-Solver">
https://github.com/sigh/Interactive-Sudoku-Solver</a>.
More projects at <a href="https://sigh.github.io/">sigh.github.io</a>.
</footer>
</body>
</html>