-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
920 lines (880 loc) · 62.9 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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A simple HTML+JS implementation of Sudoku by Ben Baryo">
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,PHN2ZyBoZ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M2LjM5MnYxNS44MjhsLTExLjgxMS0wLjE2bDExLjgxMS0xNS43MDlWMTIzNi4zOTJ6Ii8+PHBhdGggc3R5bGU9ImZpbGw6I0ZGRkZGRjsiIGQ9Ik0zMDMuOTYxLDExODAuMzQ5aDEyOC4wMzJ2MTI4LjAzMUgzMDMuOTYxVjExODAuMzQ5eiIvPjxwYXRoIHN0eWxlPSJmaWxsOiNFQkZFRkY7IiBkPSJNMzE1Ljk3NywxMTkyLjMxOGgxMDR2MTA0LjA5NmgtMTA0VjExOTIuMzE4eiIvPjxwYXRoIHN0eWxlPSJmaWxsOiNGRkZGRkY7IiBkPSJNMTU5Ljk4NSwxMzI0LjMyNmgxMjguMDMydjEyOC4wMzFIMTU5Ljk4NUwxNTkuOTg1LDEzMjQuMzI2TDE1OS45ODUsMTMyNC4zMjZ6Ii8+PHBhdGggc3R5bGU9ImZpbGw6I0VCRkVGRjsiIGQ9Ik0xNzIuMDAxLDEzMzYuMjk1aDEwNHYxMDQuMDk2aC0xMDRWMTMzNi4yOTV6Ii8+PC9nPjwvc3ZnPg==">
<title>Sudoku</title>
<style>
:root {
--background-color-base: bisque;
--background-color-selected: burlywood;
--body-background-color: rgba(0, 0, 0, 0.56);
--dialog-background-color: #272734;
--dialog-font-color: bisque;
--font-color-base: black;
--font-color-selected: #05ea10;
--font-color-highlight: #8d1fea;
--font-size-base: 20px;
}
body {
align-items: center;
display: flex;
flex-direction: column;
font-size: var(--font-size-base);
gap: .5rem;
background-color: var(--body-background-color);
color: white;
}
.buttons-group {
/*noinspection CssUnusedSymbol*/
.active {
background-color: #33A5D2;
}
button {
background-color: transparent;
}
svg {
width: 2rem;
height: 2rem;
}
}
dialog {
text-align: center;
background-color: var(--dialog-background-color);
color: var(--dialog-font-color);
}
table {
border-collapse: collapse;
}
#board {
user-select: none;
td {
background-color: var(--background-color-base);
color: var(--font-color-base);
font-size: larger;
text-align: center;
padding: 0;
}
[class^="col-"] {
border: .2rem solid black;
}
[data-cell] {
border: 1px solid black;
height: 3rem;
width: 4rem;
&:hover {
filter: brightness(110%);
cursor: pointer;
}
@media (max-width: 500px) {
height: 3rem;
}
}
[data-name="pencil-marks"] {
height: 100%;
width: 100%;
}
[data-pencil] {
font-size: .8rem;
height: calc(3rem / 3.1);
width: calc(4rem / 3.1);
@media (max-width: 500px) {
font-size: .5rem;
}
}
/*noinspection CssUnusedSymbol*/
.selected {
background-color: var(--background-color-selected);
color: var(--font-color-selected);
}
/*noinspection CssUnusedSymbol*/
.highlight-digit {
color: var(--font-color-highlight);
}
}
#keyboard {
user-select: none;
button {
font-size: larger;
height: 3rem;
width: 3rem;
}
td {
padding: 0;
}
/*noinspection CssUnusedSymbol*/
.selected {
background-color: #2782d2;
}
/*noinspection CssUnusedSymbol*/
.disabled {
filter: brightness(.6);
}
}
header {
display: flex;
align-items: center;
background-color: #272734;
width: 100%;
height: 2rem;
justify-content: space-between;
&> * {
padding: 0 .5rem;
}
.github-icon {
width: 1.5rem;
height: 1.5rem;
}
.icons {
display: flex;
svg {
width: 1.5rem;
height: 1.5rem;
}
}
}
main {
align-items: center;
display: flex;
flex-direction: column;
gap: .5rem;
}
#undo {
&:disabled > svg {
fill: gray;
}
}
#redo {
transform: scaleX(-1);
&:disabled > svg {
fill: gray;
}
}
.hide {
display: none;
}
[role="button"] {
&:active {
transform: translate(2px, 2px);
animation: transform 0.02 ease;
}
}
</style>
</head>
<body>
<header>
<span role="button" class="icons" title="Sudoku" aria-label="About" onclick="document.getElementById('about-modal').showModal()">
<img width="30" height="30" src="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIwMHB4IiB3aWR0aD0iMjAwcHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDQ0OC4wMDEgNDQ4LjAwMSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgc3Ryb2tlPSIjMDAwMDAwIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0xMD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7IiBkPSJNMzE1Ljk3NywxMTkyLjMxOGgxMDR2MTA0LjA5NmgtMTA0VjExOTIuMzE4eiIvPjxwYXRoIHN0eWxlPSJmaWxsOiNGRkZGRkY7IiBkPSJNMTU5Ljk4NSwxMzI0LjMyNmgxMjguMDMydjEyOC4wMzFIMTU5Ljk4NUwxNTkuOTg1LDEzMjQuMzI2TDE1OS45ODUsMTMyNC4zMjZ6Ii8+PHBhdGggc3R5bGU9ImZpbGw6I0VCRkVGRjsiIGQ9Ik0xNzIuMDAxLDEzMzYuMjk1aDEwNHYxMDQuMDk2aC0xMDRWMTMzNi4yOTV6Ii8+PC9nPjwvc3ZnPg==" alt="Sudoku Icon">
</span>
<span id="timer">00:00</span>
<button aria-label="New Game" onclick="initBoard(true)">New Game</button>
<span class="github-icon" title="Click to view source code on GitHub">
<a href="https://github.com/ctrl-escp/sudoku" target="_blank" aria-label="Link to the GitHub repo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="white" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
</a>
</span>
</header>
<main>
<table id="board">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td data-cell="1-1"><span data-name="value"></span></td>
<td data-cell="1-2"><span data-name="value"></span></td>
<td data-cell="1-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="2-1"><span data-name="value"></span></td>
<td data-cell="2-2"><span data-name="value"></span></td>
<td data-cell="2-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="3-1"><span data-name="value"></span></td>
<td data-cell="3-2"><span data-name="value"></span></td>
<td data-cell="3-3"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="1-4"><span data-name="value"></span></td>
<td data-cell="1-5"><span data-name="value"></span></td>
<td data-cell="1-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="2-4"><span data-name="value"></span></td>
<td data-cell="2-5"><span data-name="value"></span></td>
<td data-cell="2-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="3-4"><span data-name="value"></span></td>
<td data-cell="3-5"><span data-name="value"></span></td>
<td data-cell="3-6"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="1-7"><span data-name="value"></span></td>
<td data-cell="1-8"><span data-name="value"></span></td>
<td data-cell="1-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="2-7"><span data-name="value"></span></td>
<td data-cell="2-8"><span data-name="value"></span></td>
<td data-cell="2-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="3-7"><span data-name="value"></span></td>
<td data-cell="3-8"><span data-name="value"></span></td>
<td data-cell="3-9"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tbody>
<tr>
<td data-cell="4-1"><span data-name="value"></span></td>
<td data-cell="4-2"><span data-name="value"></span></td>
<td data-cell="4-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="5-1"><span data-name="value"></span></td>
<td data-cell="5-2"><span data-name="value"></span></td>
<td data-cell="5-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="6-1"><span data-name="value"></span></td>
<td data-cell="6-2"><span data-name="value"></span></td>
<td data-cell="6-3"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="4-4"><span data-name="value"></span></td>
<td data-cell="4-5"><span data-name="value"></span></td>
<td data-cell="4-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="5-4"><span data-name="value"></span></td>
<td data-cell="5-5"><span data-name="value"></span></td>
<td data-cell="5-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="6-4"><span data-name="value"></span></td>
<td data-cell="6-5"><span data-name="value"></span></td>
<td data-cell="6-6"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="4-7"><span data-name="value"></span></td>
<td data-cell="4-8"><span data-name="value"></span></td>
<td data-cell="4-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="5-7"><span data-name="value"></span></td>
<td data-cell="5-8"><span data-name="value"></span></td>
<td data-cell="5-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="6-7"><span data-name="value"></span></td>
<td data-cell="6-8"><span data-name="value"></span></td>
<td data-cell="6-9"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tbody>
<tr>
<td data-cell="7-1"><span data-name="value"></span></td>
<td data-cell="7-2"><span data-name="value"></span></td>
<td data-cell="7-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="8-1"><span data-name="value"></span></td>
<td data-cell="8-2"><span data-name="value"></span></td>
<td data-cell="8-3"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="9-1"><span data-name="value"></span></td>
<td data-cell="9-2"><span data-name="value"></span></td>
<td data-cell="9-3"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="7-4"><span data-name="value"></span></td>
<td data-cell="7-5"><span data-name="value"></span></td>
<td data-cell="7-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="8-4"><span data-name="value"></span></td>
<td data-cell="8-5"><span data-name="value"></span></td>
<td data-cell="8-6"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="9-4"><span data-name="value"></span></td>
<td data-cell="9-5"><span data-name="value"></span></td>
<td data-cell="9-6"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td data-cell="7-7"><span data-name="value"></span></td>
<td data-cell="7-8"><span data-name="value"></span></td>
<td data-cell="7-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="8-7"><span data-name="value"></span></td>
<td data-cell="8-8"><span data-name="value"></span></td>
<td data-cell="8-9"><span data-name="value"></span></td>
</tr>
<tr>
<td data-cell="9-7"><span data-name="value"></span></td>
<td data-cell="9-8"><span data-name="value"></span></td>
<td data-cell="9-9"><span data-name="value"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class="buttons-group">
<button id="inputMethod" onclick="togglePencil()" aria-label="Toggle Input Type">
<span class="pencil hide">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xml:space="preserve"><polygon style="fill:#FBE6B7;" points="180.006,414.017 171.785,422.16 115.097,478.926 115.019,478.926 113.923,480.023 113.844,479.945 113.375,479.474 113.297,479.474 73.6,439.701 72.895,439.074 72.19,438.29 32.494,398.671 31.867,398.046 97.95,331.961"/><path style="fill:#FFFFFF;" d="M511.439,67.631c-0.627,2.739-2.036,5.402-4.15,7.516l-35.938,35.937l-7.673,7.673l-4.15,4.15 c-6.264,6.264-16.599,6.264-22.941,0l-23.724-23.724L389.06,75.38c-6.342-6.341-6.342-16.676,0-22.941l4.15-4.15l7.673-7.673 l9.552-9.552L436.743,4.68c2.114-2.114,4.776-3.525,7.595-4.15c5.324-1.409,11.275,0,15.425,4.15l23.724,23.803l23.802,23.722 C511.439,56.355,512.848,62.305,511.439,67.631z"/><polygon style="fill:#FEF9E7;" points="477.145,116.88 404.72,189.306 363.692,148.276 322.664,107.248 395.089,34.823 471.351,111.085"/><polygon style="fill:#BBBA9C;" points="486.697,107.248 477.145,116.88 469.472,124.473 463.678,118.757 393.21,48.29 387.416,42.498 404.641,25.271 480.903,101.533"/><polygon style="fill:#EDA8AA;" points="417.874,176.072 404.72,189.306 309.901,284.123 180.006,414.017 171.785,422.16 130.835,381.134 89.808,340.105 97.95,331.961 227.845,202.067 322.664,107.248 335.818,94.095 376.846,135.122"/><path style="fill:#FBE6B7;" d="M115.019,478.926l-1.096,0.314l-0.548,0.235h-0.078l-72.112,20.907 c-0.078-0.157-0.157-0.237-0.157-0.392c-3.132-6.029-7.125-11.745-12.214-16.835c-5.089-5.089-10.805-9.16-16.912-12.215 c-0.078-0.076-0.235-0.076-0.313-0.157l20.906-72.112l0.235-0.703l0.314-1.097l0.861,0.862L74.07,437.9l1.488,1.487l38.601,38.6 L115.019,478.926z"/><path style="fill:#25cb28;" d="M41.654,499.833l-0.626,0.157l-0.078,0.078l-26.543,7.751L0,511.969l4.15-14.407l7.751-26.622 l0.235-0.703c6.186,3.131,12.058,7.203,17.226,12.372C34.529,487.775,38.601,493.647,41.654,499.833z"/><polygon style="fill:#EDA8AA;" points="309.901,284.123 180.006,414.017 115.097,478.926 113.766,480.258 113.844,479.945 113.923,479.239 114.158,477.987 122.457,431.087 75.557,439.387 73.6,439.701 71.955,440.012 71.877,440.012 72.19,438.29 72.504,436.333 80.803,389.432 33.903,397.732 32.728,397.968 31.945,398.124 31.789,398.124 97.95,331.961 227.845,202.067"/><polygon style="fill:#FBE6B7;" points="180.006,414.017 171.785,422.16 115.097,478.926 115.019,478.926 113.923,480.023 113.844,479.945 113.375,479.474 113.297,479.474 73.6,439.701 72.895,439.074 72.19,438.29 32.494,398.671 31.867,398.046 97.95,331.961"/><path style="fill:#FFFFFF;" d="M511.439,67.631c-0.627,2.739-2.036,5.402-4.15,7.516l-35.938,35.937l-7.673,7.673l-4.15,4.15 c-6.264,6.264-16.599,6.264-22.941,0l-23.724-23.724L389.06,75.38c-6.342-6.341-6.342-16.676,0-22.941l4.15-4.15l7.673-7.673 l9.552-9.552L436.743,4.68c2.114-2.114,4.776-3.525,7.595-4.15c5.324-1.409,11.275,0,15.425,4.15l23.724,23.803l23.802,23.722 C511.439,56.355,512.848,62.305,511.439,67.631z"/><polygon style="fill:#FEF9E7;" points="477.145,116.88 404.72,189.306 363.692,148.276 322.664,107.248 395.089,34.823 471.351,111.085"/><polygon style="fill:#BBBA9C;" points="486.697,107.248 477.145,116.88 469.472,124.473 463.678,118.757 393.21,48.29 387.416,42.498 404.641,25.271 480.903,101.533"/><polygon style="fill:#EDA8AA;" points="417.874,176.072 404.72,189.306 309.901,284.123 180.006,414.017 171.785,422.16 130.835,381.134 89.808,340.105 97.95,331.961 227.845,202.067 322.664,107.248 335.818,94.095 376.846,135.122"/><path style="fill:#FBE6B7;" d="M115.019,478.926l-1.096,0.314l-0.548,0.235h-0.078l-72.112,20.907 c-0.078-0.157-0.157-0.237-0.157-0.392c-3.132-6.029-7.125-11.745-12.214-16.835c-5.089-5.089-10.805-9.16-16.912-12.215 c-0.078-0.076-0.235-0.076-0.313-0.157l20.906-72.112l0.235-0.703l0.314-1.097l0.861,0.862L74.07,437.9l1.488,1.487l38.601,38.6 L115.019,478.926z"/><path style="fill:#25cb28;" d="M41.654,499.833l-0.626,0.157l-0.078,0.078l-26.543,7.751L0,511.969l4.15-14.407l7.751-26.622 l0.235-0.703c6.186,3.131,12.058,7.203,17.226,12.372C34.529,487.775,38.601,493.647,41.654,499.833z"/><polygon style="fill:#EDA8AA;" points="309.901,284.123 180.006,414.017 115.097,478.926 113.766,480.258 113.844,479.945 113.923,479.239 114.158,477.987 122.457,431.087 75.557,439.387 73.6,439.701 71.955,440.012 71.877,440.012 72.19,438.29 72.504,436.333 80.803,389.432 33.903,397.732 32.728,397.968 31.945,398.124 31.789,398.124 97.95,331.961 227.845,202.067"/><path style="opacity:0.08;fill:#040000;" d="M480.94,101.506l26.324-26.324c6.315-6.315,6.314-16.646,0-22.961L483.5,28.457 L0.016,511.941l40.964-11.888c0.056,0.11,0.124,0.215,0.178,0.325l72.172-20.943l0.49,0.49l-0.056,0.317l0.187-0.187l57.868-57.868 l8.176-8.176l129.927-129.927l94.799-94.799l13.182-13.182l51.598-51.598l7.613-7.613l9.608-9.608L480.94,101.506z"/></svg>
</span>
<span class="pen">
<svg viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg"><path d="M11.83 121.98c5.36-2.78 13.09-8.23 23.31-16.66l-12.1-12c-8.33 10.12-13.78 17.85-16.56 23.31c2.97.09 5.25 2.47 5.35 5.35z" fill="#bdbdbd"/><path d="M4.88 123.56c.79.79 2.58.5 5.26-.79c.5-.2 1.09-.5 1.59-.79a5.536 5.536 0 0 0-5.36-5.36c-.3.6-.6 1.09-.79 1.59c-1.19 2.68-1.39 4.56-.7 5.35z" fill="#2eba2c"/><path d="M11.91 113.51c-.16.14-.33.28-.5.43c-.31.26-.68.54-1.08.44c.18-.73.57-1.39.95-2.04c2.78-4.7 4.81-8.29 8.83-12.06c.27-.25.57-.51.93-.57c.59-.09 1.11.39 1.43.88c.33.5.86 1.45.77 2.08c-.09.67-.83 1.07-1.33 1.52c-3.65 3.29-6.26 6.09-10 9.32z" fill="#eee"/><path d="M107.87 7.78c-1.01-.89-2.8-2.52-2.8-2.52c-1.01-.89-2.33-1.33-3.71-1.25c-1.38.09-2.63.69-3.5 1.67c-3.99 3.9-7.99 7.8-11.98 11.7c-5.44 5.32-18.63 18.25-19.51 19.35c-.88 1.11-.29 1.73-.19 1.84c1.32 1.45 3.69 1.65 5.42.71c1.72-.94 2.81-2.81 3.13-4.75c.21-1.26.29-1.89 1.22-2.71c.34-.3 19.29-17.99 22.19-21.29c.48-.55 1.92-1.7 3.5-.49c.25.19 5.73 4.81 5.73 4.81l3.49-3.96l-.01-.23c-.02-.27-.02-.27-2.98-2.88z" fill="#bdbdbd"/><path d="M73.4 55l-7.64-7.64C34.62 78.91 23.67 91.02 20.98 94.49c-.47.61-.42 1.47.13 2.02l10.87 10.48c.55.55 1.41.6 2.02.13c3.47-2.69 15.6-13.23 47.14-44.37c-.1-.11-7.74-7.75-7.74-7.75z" fill="#1565c0"/><path d="M123.11 17l-.1-.1c1.19-2.58-.4-5.56-3.18-8.24c-2.78-2.68-5.76-4.37-8.24-3.18l-.1-.1S88.07 21.75 63.07 47.95c-.69.79-.69 1.98 0 2.68l14.88 14.88c.69.69 1.89.79 2.68 0C106.74 40.42 123.11 17 123.11 17z" fill="none"/><path d="M104.91 10.47c-.62-.96-2.13-2.32-3.17-2.79c-1.19-.53-2.07-.01-2.83.66c-1.34 1.18-10.25 10.43-12.2 12.86c-.22.28-.45.59-.45.94c5.09-4.83 10.27-9.6 11.92-11.03c1.26-1.09 2.48-2.06 3.47-1.07c.1.1.79.65 2.04 1.7l1.22-1.27z" fill="#757575"/><path d="M123.11 17c1.23-1.77-.5-5.66-3.27-8.34c-2.78-2.68-6.57-4.54-8.34-3.27c-1.76 1.27-23.42 16.37-48.42 42.57c-.69.79-.69 1.98 0 2.68l14.88 14.88c.69.69 1.89.79 2.68 0c26.1-25.1 41.25-46.75 42.47-48.52z" fill="#1565c0"/><path d="M29.36 94.04c-1.11.87-4.4 2.43-1.87-1.53c.6-.93 2.63-3.44 3.49-4.45c3.31-3.92 22.27-23.09 25.64-26.63c2.74-2.88 5.16-3.58 5.95-1.58c.54 1.38-.58 2.98-6.42 9.2c-4.86 5.16-21.04 20.44-26.79 24.99z" fill="#2196f3"/><path d="M83.73 40.95s-3.51 4.24-6.06 2.09c-2.02-1.71 2.66-5.76 2.66-5.76c.12-.13 16.17-15.21 20.94-19.04c1.96-1.58 4.46-3.34 5.15-2.73c.69.61-.45 2.55-3.46 5.54c-3.02 2.99-19.12 19.78-19.23 19.9z" fill="#2196f3"/><path d="M123.11 17l-.1-.1c1.19-2.58-.4-5.56-3.18-8.24c-2.78-2.68-5.76-4.37-8.24-3.18l-.1-.1S88.07 21.75 63.07 47.95c-.69.79-.69 1.98 0 2.68l14.88 14.88c.69.69 1.89.79 2.68 0C106.74 40.42 123.11 17 123.11 17z" fill="none"/><path d="M72.33 32.5c-.78.51-.47 2.84-.95 4.03c-.39.95-.38 1.45.42 1.21c.85-.26 1.8-1.54 1.8-3.53c-.01-.97-.46-2.25-1.27-1.71z" fill="#eee"/><path d="M104.05 10.92l-.9.7c2.1 1.29 4.75 3.28 7.48 6.01c1.21 1.21 2.88 3.14 3.46 4.31c.54 1.11.74 2.81.28 4.4c-.5 1.73-1.29 2.51-1.61 4.27c1.59-1.97 4.8-6.08 4.8-6.08s-1.39-3.57-6.14-8.33s-7.37-5.28-7.37-5.28z" fill="#0d47a1"/><path d="M119.84 8.66c-2.15-2.07-4.9-3.65-6.85-3.68c0 0 3.51 1.88 5.53 4.51c2.14 2.78 3.53 5.31 2.57 6.9c-1.6 2.3-15.78 22.43-40.78 46.66a.964.964 0 0 1-1.48-.16c-1.42-2.19-3.32-4.5-6.16-7.33c-4.06-4.06-6.68-5.89-9.73-7.43c0 0-.7.37-.88 1.6c-.12.79-.05 1.43-.05 1.43l.86-.79c2.39 1.34 5.3 3.5 8.4 6.61c1.33 1.33 2.53 2.67 3.57 3.96c.14.26 1.18 2.46-.95 5.87c0 0-.32.41-.8 1.05c-25.03 24.55-36.67 35.02-38.96 36.58c-2.4 1.63-3.67 1.08-3.67 1.08c.3.3.96 1.04 1.7 1.62c.75.59 1.56.19 1.83-.03c2.9-2.25 11.84-9.97 33.07-30.58c.03-.03.06-.05.08-.08c3.12-3.03 6.51-6.34 10.18-9.95c.02 0 .65.07 1.43-.05c1.22-.18 1.68-.75 1.68-.75v-.01c.07-.05.14-.11.21-.17c26.1-25.1 41.24-46.75 42.47-48.52s-.49-5.66-3.27-8.34z" fill="#0d47a1"/><path d="M77.08 51.17c-3.07-3.07-6.64-5.88-9.83-7.51c0 0-.79-.05-1.53.77c-.56.62-.69 1.5-.69 1.5c2.42 1.07 5.96 3.36 9.95 7.34c3 3 5.44 6.16 6.87 8.92c.29.56.51 1.05.68 1.5c0 0 .88.01 1.62-.63c.83-.73.66-1.61.66-1.61c-1.58-3.31-4.51-7.06-7.73-10.28z" fill="#ffc107"/><path d="M115.15 13.11c-2.07-2.07-4.37-4.01-6.62-5.56c0 0-1.54-.59-2.95.71s-1.52 2.67-1.52 2.67c2.1 1.29 4.61 3.21 7.34 5.94c2.55 2.55 4.69 5.23 6.16 7.67c0 0 1.56-.12 2.66-1.43s.71-3.05.71-3.05c-1.58-2.37-3.61-4.78-5.78-6.95z" fill="#bdbdbd"/><path d="M107.19 8.77c-.53.11-1.03.52-1.06 1.06c-.03.55.41.99.82 1.36c1.28 1.16 2.61 2.34 4.25 2.89c.36.12.83.19 1.08-.1c.16-.18.17-.45.15-.69c-.08-.99-.58-1.9-1.23-2.65c-1.02-1.16-2.36-2.21-4.01-1.87z" fill="#eee"/></svg>
</span>
</button>
<button id="eraser" onclick="toggleEraser()" aria-label="Toggle Eraser">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 506 506" xml:space="preserve" fill="#ffffff"><path style="fill:#DF5C4E;" d="M193,215.7c-0.8-0.8-0.8-2,0-2.8s2-0.8,2.8,0l150,150l140-140c9.2-9.2,14.4-21.6,14.4-35.2 s-5.2-25.6-14.4-35.2l-106-105.6c-9.2-9.2-21.6-14.4-35.2-14.4s-25.6,5.2-35.2,14.4L20.2,335.7C1,355.3,1,386.9,20.2,406.1 l67.6,67.6h147.6L343,366.1L193,215.7z"/><path style="fill:#33A5D2;" d="M193,215.7c-0.8-0.8-0.8-2,0-2.8s2-0.8,2.8,0l150,150l140-140c9.2-9.2,14.4-21.6,14.4-35.2 s-5.2-25.6-14.4-35.2l-106-105.6c-9.2-9.2-21.6-14.4-35.2-14.4s-25.6,5.2-35.2,14.4L166.6,189.7l176,176L193,215.7z"/><path style="fill:#E36D60;" d="M168.2,191.3L11.4,348.5c-6.8,13.2-7.2,29.2-0.8,43.2l179.2-179.2L168.2,191.3z"/><path style="fill:#73BADD;" d="M189.4,212.5l176-175.6c-6.4-2.8-13.6-4.4-20.8-4.4c-8,0-15.6,2-22.4,5.6l-154,153.2L189.4,212.5z"/><path d="M236.2,479.7H86.6c-1.2,0-2-0.4-2.8-1.2l-67.6-68c-21.6-21.6-21.6-57.2,0-78.8l2.8,2.8l-2.8-2.8L305.4,42.5 c21.6-21.6,56.8-21.6,78.4,0l106,106c21.6,21.6,21.6,57.2,0,78.8L239,478.5C238.2,479.3,237.4,479.7,236.2,479.7z M88.2,471.7h146.4 l249.6-250c8.8-8.8,14-20.8,14-33.6c0-12.8-4.8-24.8-14-33.6l-106-106c-18.4-18.4-48.8-18.4-67.2,0L21.8,337.7 c-18.4,18.4-18.4,49.2,0,67.6L88.2,471.7z"/><path d="M365,479.7H89c-2.4,0-4-1.6-4-4s1.6-4,4-4h276c2.4,0,4,1.6,4,4S367.4,479.7,365,479.7z"/><path d="M345,368.9c-1.2,0-2-0.4-2.8-1.2L191.4,217.3c-1.6-1.6-1.6-4,0-5.6s4-1.6,5.6,0l150.8,150.4c1.6,1.6,1.6,4,0,5.6 C347,368.5,346.2,368.9,345,368.9z"/><path d="M445,463.7H253c-2.4,0-4-1.6-4-4s1.6-4,4-4h192c2.4,0,4,1.6,4,4S447.4,463.7,445,463.7z"/></svg>
</button>
<button id="undo" onclick="undoRedo()" aria-label="Undo" title="Undo last action" disabled>
<svg viewBox="-7 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#ffffff"><path d="M7.75 13.313v2.063c0 0.438-0.344 0.625-0.688 0.375l-6.781-4.875c-0.375-0.25-0.375-0.719 0-0.969l6.781-4.906c0.344-0.25 0.688-0.094 0.688 0.344v2.031c1.531 0 4.688 0.188 6.75 1.531 4.719 3.094 7.438 13.219-8 18.344 0 0 9.313-4.656 7.688-11.063-0.406-1.719-2.313-3.25-6.438-2.875z"/></svg>
</button>
<button id="redo" onclick="undoRedo(true)" aria-label="Undo" title="Redo last undo" disabled>
<svg viewBox="-7 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#ffffff"><path d="M7.75 13.313v2.063c0 0.438-0.344 0.625-0.688 0.375l-6.781-4.875c-0.375-0.25-0.375-0.719 0-0.969l6.781-4.906c0.344-0.25 0.688-0.094 0.688 0.344v2.031c1.531 0 4.688 0.188 6.75 1.531 4.719 3.094 7.438 13.219-8 18.344 0 0 9.313-4.656 7.688-11.063-0.406-1.719-2.313-3.25-6.438-2.875z"/></svg>
</button>
</div>
<table id="keyboard">
<tbody>
<tr>
<td>
<button id="1">1</button>
</td>
<td>
<button id="2">2</button>
</td>
<td>
<button id="3">3</button>
</td>
</tr>
<tr>
<td>
<button id="4">4</button>
</td>
<td>
<button id="5">5</button>
</td>
<td>
<button id="6">6</button>
</td>
</tr>
<tr>
<td>
<button id="7">7</button>
</td>
<td>
<button id="8">8</button>
</td>
<td>
<button id="9">9</button>
</td>
</tr>
</tbody>
</table>
</main>
<template id="pencil-board">
<table data-name="pencil-marks">
<tbody>
<tr>
<td data-pencil="1"></td>
<td data-pencil="2"></td>
<td data-pencil="3"></td>
</tr>
<tr>
<td data-pencil="4"></td>
<td data-pencil="5"></td>
<td data-pencil="6"></td>
</tr>
<tr>
<td data-pencil="7"></td>
<td data-pencil="8"></td>
<td data-pencil="9"></td>
</tr>
</tbody>
</table>
</template>
<dialog id="about-modal">
<h2>About</h2>
<p>
Developed by Ben Baryo
</p>
<button aria-label="Close Modal" onclick="document.getElementById('about-modal').close()">Close</button>
</dialog>
<dialog id="game-won-modal">
<h2>Congratulations!</h2>
<p>You solved the puzzle!</p>
<button aria-label="Close Modal" onclick="document.getElementById('game-won-modal').close()">Close</button>
</dialog>
<script>
const board = document.getElementById('board');
const timerEl = document.getElementById('timer');
const skBoardState = 'sudoku_board_state';
const skChallenge = 'sudoku_challenge';
const skSolution = 'sudoku_solution';
const skGameTime = 'sudoku_game_time';
let gameStartTime;
let gameTimerIntervalId;
let selectedCell;
let selectedBtn;
let isPencil = false;
let isEraser = false;
let solution;
let challenge;
const actionsTaken = []; // For undo
const actionsCancelled = []; // For re-do
/**
* @param {number} [time]
*/
function updateTimer(time) {
const timeStr = String(time || Math.floor((performance.now() - gameStartTime) / 1000));
timerEl.innerText = `${String(Math.floor(timeStr / 60)).substring(0, 2).padStart(2, '0')}:${String(timeStr % 60).padStart(2, '0')}`;
}
function startTimer() {
gameTimerIntervalId = setInterval(updateTimer, 1000);
timerEl.innerText = '00:00';
}
function stopTimer() {
// noinspection JSVoidFunctionReturnValueUsed
gameTimerIntervalId = clearInterval(gameTimerIntervalId);
gameStartTime = undefined;
}
/**
* @returns {number[]} Retrieve all digits from the board
*/
function getAllDigitsOnBoard() {
return Array.from(document.querySelectorAll('[data-name="value"]'), el => Number(el.innerText) || 0);
}
/**
* Retrieve all values from the board in the form of 9 rows
* @returns {number[][]}
*/
function getBoardValues() {
const vals = getAllDigitsOnBoard();
/*
Since the values are returned as a concatenation of boxes:
123 123 123
456 456 456 => 123456789123456789123456789
789 789 789
they will be parsed into rows => 123123123456456456789789789
*/
const board = Array.from({length: 9}, () => []);
let rowIdx = 0;
let rowDiff = 0;
for (let i = 0; i < 81; i += 3) {
if (rowDiff > 2) rowDiff = 0;
rowIdx = (Math.floor(i / 27) * 3) + rowDiff;
board[rowIdx].push(...vals.slice(i, i + 3));
rowDiff++;
}
return board;
}
function togglePencil() {
isPencil = !isPencil;
document.querySelector('.pencil').classList[isPencil ? 'remove' : 'add']('hide');
document.querySelector('.pen').classList[isPencil ? 'add' : 'remove']('hide');
}
function toggleEraser() {
isEraser = !isEraser;
document.getElementById('eraser').classList[isEraser ? 'add' : 'remove']('active');
}
function undoRedo(redo=false) {
const stack = redo ? actionsCancelled : actionsTaken;
const action = stack.pop();
if (!action) throw new Error(`${redo ? 'Re' : 'Un'}do stack is empty`);
(redo ? actionsTaken : actionsCancelled).push({
target: action.target,
state: action.target.innerHTML,
});
action.target.innerHTML = action.state;
document.getElementById('undo').disabled = actionsTaken.length ? '' : 'disabled';
document.getElementById('redo').disabled = actionsCancelled.length ? '' : 'disabled';
saveBoardState();
highlightDigits();
reviewKeyboardDigits();
}
/**
* Callback function for clicking on cells
* @param {event} e
*/
function cellClick(e) {
const cell = e.currentTarget;
// Clear previously highlighted cell and highlight the one currently clicked
// If the same cell is clicked, simply toggle the highlight
selectedCell?.classList?.remove('selected');
selectedCell = selectedCell === cell ? null : cell;
selectedCell?.classList?.add('selected');
// Only change cells which aren't marked as hardcoded
if (!cell.dataset.hardcoded) {
actionsTaken.push({
target: cell,
state: cell.innerHTML,
});
actionsCancelled.length = 0;
if (isEraser) {
cell.children[0].innerText = '';
cell.children[1].querySelectorAll('td').forEach(el => el.innerText = '');
}
else if (selectedBtn) {
if (!gameStartTime) {
gameStartTime = performance.now();
startTimer();
}
const val = selectedBtn.id;
if (isPencil) {
// Show the pencil board and toggle the digit on it
if (cell.children[0].innerText) return;
const pencilBoard = cell.children[1];
pencilBoard.classList.remove('hide');
const mark = pencilBoard.querySelector(`td[data-pencil="${val}"]`);
mark.innerText = mark.innerText === String(val) ? '' : val;
}
else {
// If the cell contains the same digit, remove it and display the pencil board
if (cell.children[0].innerText === String(val)) {
cell.children[0].innerText = '';
cell.children[1].classList.remove('hide');
} else {
// Otherwise write the value into the cell and check if the game is solved
cell.children[1].classList.add('hide');
cell.children[0].innerText = val;
if (isBoardSolved(getBoardValues())) {
stopTimer();
document.getElementById('game-won-modal').showModal();
}
}
}
}
selectedCell = cell;
selectedCell.classList.add('selected');
saveBoardState();
highlightDigits();
reviewKeyboardDigits();
}
document.getElementById('undo').disabled = actionsTaken.length ? '' : 'disabled';
document.getElementById('redo').disabled = actionsCancelled.length ? '' : 'disabled';
}
/**
* @param {string} sequence
* @returns {boolean} True if the sequence contains 9 digits between 1 and 9 with no redundancies
*/
function validate1to9Range(sequence) {
return (new RegExp('^[1-9]{9}$')).test(sequence) && !(new RegExp('(\\d).*\\1').test(sequence));
}
/**
* @param {number[][]} board
* @returns {boolean} True if the bored is a valid sudoku board
*/
function isBoardSolved(board) {
const cols = Array.from({length: 9}, () => []);
for (const row of board) {
if (!validate1to9Range(row.join(''))) return false;
for (let i = 0; i < 9; i++) cols[i].push(row[i]);
}
for (let i = 0; i < 9; i++) {
if (!validate1to9Range(cols[i].join(''))) return false;
}
return true;
}
/**
* @param {number[][]} board
* @param {number} [difficulty]
* @returns {number[][]}
*/
function generateChallenge(board, difficulty) {
const maxRemovedDigits = 40;
let numOfDigitsToRemove = Math.floor(maxRemovedDigits / difficulty);
const challenge = JSON.parse(JSON.stringify(board));
const rows = getRandomArrayLength9();
const cols = getRandomArrayLength9();
for (; numOfDigitsToRemove; numOfDigitsToRemove--) {
if (!rows.length) {
rows.push(...getRandomArrayLength9());
cols.push(...getRandomArrayLength9());
}
const row = rows.shift();
const col = cols.shift();
challenge[row][col] = 0;
}
return challenge;
}
/**
* Generate a new challenge and hard code the available values on a clean board.
* @param {boolean} [fresh] If false, attempt to load saved state before generating a new puzzle
* @param {number} [difficulty] WiP TODO: finish implementing
*/
function initBoard(fresh = false, difficulty = 1) {
timerEl.innerText = '00:00';
const savedState = loadBoardState();
const isLoaded = !fresh && savedState;
let values;
if (isLoaded) {
values = savedState;
} else {
if (fresh) saveBoardState(true);
solution = generateSudoku();
challenge = generateChallenge(solution, difficulty);
values = JSON.parse(JSON.stringify(challenge));
}
quickPrintBoard(solution);
for (let i = 0; i < 9; i++) {
const row = Array.from(board.querySelectorAll(`[data-cell^="${i + 1}"]`));
for (const cell of row) {
delete cell.dataset.hardcoded;
cell.children[1]?.remove();
const val = values[i].shift();
const isHardcodedValue = val > 0;
cell.children[0].innerText = isHardcodedValue ? val : '';
if (isHardcodedValue) cell.dataset.hardcoded = 'true';
else {
const pencilBoard = document.getElementById('pencil-board').content.children[0].cloneNode(true);
cell.querySelector('[data-name="pencil-marks"]')?.remove();
cell.appendChild(pencilBoard);
}
cell.removeEventListener('click', cellClick);
cell.addEventListener('click', cellClick);
}
}
saveBoardState();
reviewKeyboardDigits();
}
function highlightDigits() {
const val = selectedBtn?.id;
board.querySelectorAll(`[data-name="value"], [data-pencil]`).forEach(el => {
if (val && (el.innerText === val || el.dataset.pencil === val)) el.classList.add('highlight-digit');
else el.classList.remove('highlight-digit');
})
}
/**
* Initialize the numeric keyboard click behavior
*/
function initKeyboard() {
function keyClick(e) {
const btn = e.target;
if (isEraser) toggleEraser();
selectedBtn?.classList?.remove('selected');
selectedBtn = selectedBtn === btn ? null : btn;
selectedBtn?.classList?.add('selected');
highlightDigits();
}
const keyboardButtons = document.querySelectorAll('#keyboard button');
for (let i = 0; i < keyboardButtons.length; i++) {
const btn = keyboardButtons[i];
btn.removeEventListener('click', keyClick);
btn.addEventListener('click', keyClick);
}
reviewKeyboardDigits();
}
function reviewKeyboardDigits() {
const boardDigitsCount = getAllDigitsOnBoard().reduce((acc, digit) => {
acc[digit] = (acc[digit] || 0) + 1;
return acc;
}, {});
for (let i = 1; i < 10; i++) {
const d = '' + i
document.getElementById(d).classList[boardDigitsCount[d] === 9 ? 'add' : 'remove']('disabled');
}
}
function getRandomArrayLength9(startAt0 = true) {
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
// Remove the first or last digit based on the start position - 0 or 1
// noinspection JSValidateTypes
arr[startAt0 ? 'pop' : 'shift']();
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
/**
* @returns {number[][]} A valid complete sudoku board
*/
function generateSudoku() {
let board = Array.from({length: 9}, () => Array.from({length: 9}, () => 0));
/**
* @param {number} r Row
* @param {number} c Column
* @returns {number[]} All of the digits in a box that corresponds to the cell at the coordinates
*/
function getBox(r, c) {
const boxStartRow = Math.floor(r / 3) * 3;
const boxStartCol = Math.floor(c / 3) * 3;
const box = [];
for (let row = boxStartRow; row < boxStartRow + 3; row++) {
for (let col = boxStartCol; col < boxStartCol + 3; col++) {
box.push(board[row][col]);
}
}
return box;
}
/**
* @param {number} r Row
* @param {number} c Column
* @param {number} d Digit
* @returns {boolean} Place the digit at the target cell if the placement is valid and return true; false otherwise
*/
function placeDigitInCell(r, c, d) {
// Validate placement on row
if (board[r].includes(d)) return false;
// Validate placement on column
for (let i = 0; i < 9; i++) {
if (board[i][c] === d) return false;
}
// Validate placement on column
if (getBox(r, c).includes(d)) return false;
// Verify target cell is empty before placing the digit
return !board[r][c] && (board[r][c] = d) && true;
}
/**
* Place a digit on each line on random columns while keeping the board valid.
* @param {number} d A digit
* @returns {boolean} True if the board is valid after the placement; false otherwise.
*/
function populateBoardWithDigit(d) {
for (let row = 0; row < 9; row++) {
const cols = getRandomArrayLength9(); // Random column placements
if (board[row].includes(d)) continue;
let col = cols.shift();
let isPlaced = false;
while (col !== undefined) {
if (placeDigitInCell(row, col, d)) {
isPlaced = true;
break;
}
col = cols.shift();
}
if (!isPlaced) return false;
}
return true;
}
const boardStates = [JSON.stringify(board)];
const digits = getRandomArrayLength9(false);
let attemptsLeft = 9;
let statesCounter = boardStates.length;
/*
- Place the same random digit on each row on random columns while keeping the board valid.
- If there isn't an order where the board can keep its validity, return to a previous state and try again
with another digit.
- Rinse and repeat
*/
while (digits.length && boardStates.length) {
if (!attemptsLeft) {
// Since none of the digits can be validly placed, revert to an earlier board state
const previousBoardDigits = [...new Set(board.flat())];
board = JSON.parse(boardStates.pop());
const currentBoardDigits =[...new Set(board.flat())];
const missingDigit = previousBoardDigits.filter(n => !currentBoardDigits.includes(n));
// Insert the missing digits back into the stack to be placed on the board
digits.push(...missingDigit);
attemptsLeft = 9;
}
boardStates.push(JSON.stringify(board));
const digit = digits.shift();
if (!populateBoardWithDigit(digit)) {
digits.push(digit);
board = JSON.parse(boardStates.pop());
if (statesCounter === boardStates.length) attemptsLeft--;
else {
statesCounter = boardStates.length;
attemptsLeft = 8;
}
}
}
return board;
}
/**
* Log the board for debug
* @param {number[][]} board
*/
function quickPrintBoard(board) {
let b = '';
for (let i = 0; i < 9; i++) {
const row = board[i];
b += [row.slice(0, 3).join(''), row.slice(3, 6).join(''), row.slice(6).join('')].join(' ');
b += !((i + 1) % 3) ? '\n\n' : '\n';
}
console.log(b);
}
function saveBoardState(clear = false) {
const action = clear ? 'removeItem' : 'setItem'
localStorage[action](skBoardState, JSON.stringify(getBoardValues()));
localStorage[action](skChallenge, JSON.stringify(challenge));
localStorage[action](skSolution, JSON.stringify(solution));
localStorage[action](skGameTime, JSON.stringify(Math.floor((performance.now() - gameStartTime) / 1000)));
}
function loadBoardState() {
challenge = JSON.parse(localStorage.getItem(skChallenge) || null);
solution = JSON.parse(localStorage.getItem(skSolution) || null);
const gameTime = parseInt(localStorage.getItem(skGameTime) || null);
if (!Number.isNaN(gameTime)) {
gameStartTime = performance.now() - gameTime;
updateTimer(gameTime);
startTimer();
}
return JSON.parse(localStorage.getItem(skBoardState) || null);
}
initKeyboard();
initBoard();
</script>
</body>
</html>