-
Notifications
You must be signed in to change notification settings - Fork 0
/
nonogram.html
163 lines (163 loc) · 10.6 KB
/
nonogram.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
<html>
<head>
<title>Nonogram</title>
<meta charset="utf-8"/>
<style>
canvas {width:600px}
@media print{h3 {page-break-before: always;}}
</style>
</head>
<body>
<p><a href="https://handsomeone.github.io/Nonogram/">https://handsomeone.github.io/Nonogram/</a></p>
<canvas id="editor"></canvas>
<canvas id="editorSolver"></canvas>
<p><button id="invert">Invert</button><button id="update">Update</button></p>
<textarea id="editorRowCol"></textarea>
<script src="https://handsomeone.github.io/Nonogram/nonogram.min.js"></script>
<script type="text/javascript">
editRows = 26;
editCols = 26;
var editor = new nonogram.Editor(
editRows,editCols,
'editor',
{
'theme': {'isMeshed':true},
'grid': new Array(editRows).fill(new Array(editCols).fill(0)),
'onHintChange': function (row,column) {
new nonogram.Solver(row, column, 'editorSolver');
document.getElementById('editorRowCol').value = JSON.stringify(this.grid);
}
}
)
var update = function() {
editor = new nonogram.Editor(
editRows,editCols,
'editor',
{
'theme': {'isMeshed':true},
'grid': JSON.parse(document.getElementById('editorRowCol').value),
'onHintChange': function (row,column) {
new nonogram.Solver(row, column, 'editorSolver');
document.getElementById('editorRowCol').value = JSON.stringify(this.grid);
}
}
)
}
var invert = function() {
editor = new nonogram.Editor(
editRows,editCols,
'editor',
{
'theme': {'isMeshed':true},
'grid': window.editor.grid.map(function(x){return x.map(function(y){return 1-y})}),
'onHintChange': function (row,column) {
new nonogram.Solver(row, column, 'editorSolver');
document.getElementById('editorRowCol').value = JSON.stringify(this.grid);
}
}
)
}
document.getElementById('invert').addEventListener('click',invert);
document.getElementById('update').addEventListener('click',update);
/* new nonogram.Solver(
[[3],[3],[1],[2],[2]],[[],[2],[5],[2,2],[]],
'intro', {'theme': {'filledColor': 'pink','isMeshed':true}},
).solve();
new nonogram.Solver(
[[3,3],[2,2],[8],[1,2,1],[1,2,1],[6],[2,2],[1,1],[6],[4]],[[1],[3],[9],[1,2,2],[4,2],[4,2],[1,2,2],[9],[3],[1]],
'easy0',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[4],[2,3],[4,2],[8],[1,5],[1,4],[1,2,2],[2,2],[2],[1]],[[4],[2,1],[4,2],[7],[1,4],[1,3],[2,4],[3,2],[2,2],[2]],
'easy1',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,2],[10],[1,2,1],[1,2,1],[8],[1,2,1],[1,2,1],[1,2,1],[4],[2]],[[2],[1,3],[2,1,2],[2,1,1],[9],[9],[2,1,1],[2,1,2],[1,3],[2]],
'easy2',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[8],[1,1],[1,1],[3,3],[1,1],[1,1,1,1,1],[1,2,2,1],[1,1,1,1],[1,2],[8]],[[5],[1,1,1],[2,1,1,1,1],[1,2,1,1],[1,2,1],[1,1,1],[1,2,2,1],[2,1,1,1],[1,1,2],[5]],
'easy3',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[5],[1,1,1],[2,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,2],[7]],[[5],[3,1],[2,1],[1,7],[3,1],[1,2,1],[1,5],[1,1],[2,1],[4]],
'easy4',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[1],[1,1],[1,1,3],[1,3,1,1],[1,1,1,2],[1,1,1,1],[1,1,1,2,1],[2,1,1,2],[2,1,2],[6]],[[5],[1,2],[2,1,2],[1,1,1],[1,2,2],[1,1,1,1],[1,1,1,1],[1,1,2,2],[2,1,2],[6]],
'easy5',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[7],[1,2],[1,2,4],[1,1,1],[1,1,4],[1,3,3],[1,1,1],[7,1],[2,1,1,2],[7]],[[9],[1,3],[1,1,1,1,1],[1,1,1,3],[1,2,1,1],[1,3],[8,1],[2,2,2],[1,5],[3]],
'easy6',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,2],[1,3,2],[1,1],[1,2,1,1],[1,1,2,1],[3,2],[1,1],[1,1],[1,2],[5]],[[3],[1,1],[1,1,5],[2,3,1],[1,1],[2,1],[1,2,2],[1,5],[2,1],[2]],
'easy7',{'theme':{'isMeshed':true}}
).solve();
new nonogram.Solver(
[[6],[5,1],[1,2,1],[1,2,3,1],[1,2,1],[1,5],[6],[2,3],[5,1],[4,1,4],[5,2],[3,1,1,1,1],[2,1,1,1,2],[1,1,1,4],[6]],[[6],[1,1],[1,2,1,1],[1,2,1,2],[2,4,4],[1,1,5,2,1],[1,2,1,1,1,2],[1,2,1,2,1,1,1],[1,1,1,2,2],[6,4,1,1],[2,1],[2,2],[1,1,1],[2,2],[4]],
'medium0', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[3,3,2],[3,2,1,1],[1,1,1,1,1,2],[2,1,1,1,2,1],[2,1,1,1,1,2],[1,2,1,1,1,1],[1,2,1,1,2,1],[2,1,2,1,1],[1,4,2,2],[3,4,2],[1,1],[1,2,2],[1,1],[1,3,1,1],[2,1,2]],[[4],[4,2],[1,1,1,1,1],[3,3,2,3],[1,1,1,4],[1,1,3,1],[1,2,2,1,1],[3,2,1,1,1],[1,1,1,1],[1,1,2,5,2],[1,1,1,1,2],[1,2,1,1,2],[1,1,1,3,1],[2,1,1],[5]],
'medium1', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[3,1,5],[2,4],[1,3,3,3],[9,2],[9,2],[8,3],[1,7,3],[2,5,4],[3,3,5],[4,1,1,1],[1,1,1,1,2,2],[1,1,1,2,5],[3,5,3],[1,1,7,1,1],[2,9,2]],[[3,5,2],[2,3,2,1],[1,3,3,2],[5,1,2,1],[6,1,2],[7,4],[1,7,3],[7,4],[6,5],[5,1,3],[1,2,1,2,2],[2,2,3,1],[3,5,3],[9,3,1],[9,2,2]],
'medium2', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[1,1,2,5,1],[2,5],[1,9],[1,2,1,3,1],[1,1,1,1,1],[1,2,1,1,1,1,2],[2,1,1,1,1],[1,1,2,1,1],[1,1,1,1,2],[1,1,6,1],[1,1,1],[1,2,3,2,1],[1,2,2,1],[2,3,1,1],[1,2,3,2]],[[1,1,2,1,1,1],[1,1,2,2,1],[2,1,1,1,3],[1,1,2,1,2,1],[1,1,2],[1,1,4,1,2],[2,2,2],[3,2,1,1,1,2],[3,1,1,2],[4,1,1,2],[4,3],[7,2,1],[1,1,1,4],[1,2,1],[1,1,2,1,1,1]],
'medium3', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[3,1,3],[1,3,3,1],[3,1,2],[1,1,1,1],[3,1,2],[3,1,3,1],[1,3,3,1],[3,1,1],[2,1,1],[3,2,1],[2,4,1],[1,1,1,1,3],[15],[1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1]],[[1,2,2,1],[2,4,3,2],[1,2,3,1,1],[1,3],[2,2,1,1],[4,4,2],[2,2,1,1],[4],[2,2,2,1,1],[3,4,2,2],[2,2,3,1],[1,2],[1,1,2,1],[13],[2,1]],
'medium4', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,1],[2,1,1],[3,1,1],[1,4,2,1],[1,2,4,2],[1,2,1,1,2],[1,1,1,1,1,1],[5,1,2],[4,1,1,1],[2,1,4,1],[1,2,2,3],[1,2,1,2,1],[3,2,1,2],[1,1,4,2],[4,1,1,1,2]],[[3,1],[1,1,2],[2,1,1,4,1],[9,1,1],[1,1,1,2,3],[1,1,2,1,1],[10,1],[1,1,3],[2,1,1,1],[7,3,3],[1,3,1],[1,2,1,1],[1,1,1,1,1],[2,1,2,2],[2,1,1,2,1]],
'medium5', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[1,3,1,1,1,1],[1,1,1],[1,1,2,1],[1,1,5,2],[1,5,2,1],[1,2,1,1,1],[1,2,1,1],[1,1,2,1],[1,1,1,1,1],[1,1],[1,1,1,2,1],[1,1,5],[1,2,5,2,1],[1,2,1,1],[2,1,2,1,1,1]],[[1,2,1,1,1,1],[1,4,1],[1,5],[1,3,3],[1,4],[1,1,3],[3,4],[1,5,1],[1,5],[4,4],[1,3,2,1],[1,4],[2,2,1,1,3,1],[1],[1,1,1,1,1,1,1]],
'medium6', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,3,2,2,2],[11,1,1],[3,2,2,2,1],[2,2,3,3,1],[2,3,2,1,2],[1,4,4,1],[1,9,1,1],[4,1,2,3,1],[5,5,2],[1,1,1,2,4],[7,6],[3,1,1,2,2],[1,6,1,1,1],[3,3,1,1,1],[6,6]],[[5,4,3],[6,2,2,2],[2,3,2,2],[2,10,1],[2,4,1,1,1,1],[3,4,4,1],[3,2,1,1,2],[2,2,8],[5,4,2],[2,2,1,2,1],[2,6,5],[1,2,1,1,2,1],[7,2,3],[1,1,4,1],[4,10]],
'medium7', {'theme': {'filledColor': 'blue','isMeshed':true}}
).solve();
new nonogram.Solver(
[[1,3,10,2],[2,2,1,4,3],[2,3,4,4],[1,3,2,1,4,1],[3,1,5,3,1],[2,3,6],[2,1,2,3,4,1],[2,4,3,4],[2,6,7],[2,1,2,1,7,1],[1,1,2,2,3,1,3],[1,2,1,1,4,4],[1,3,2,1,2,1,3],[1,4,1,8],[2,6,8]],[[1,10],[6,1],[1,2,4],[4,7],[5,2,3],[5,2],[4,9],[5,1,3],[1,1,3,3,1],[2,5,5],[1,1,5],[5,5],[4,7],[5,8],[2,7,1,2],[1,7,3],[1,5,1,2],[3,2,6],[3,1,5],[3,3,6]],
'hard0', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[1,2,4,1,1,2,2],[1,1,1,1,4,1],[2,1,2,2],[2,3,5,2],[3,1,1,1,2,1,1],[2,3,3,1,2],[1,1,1,1,1,1,1,1],[3,3,3,1,1,2],[1,1,1,1,1,1,1,1,1,1],[2,3,3,3,3],[1,1,1,1,1,1,1,3,1],[3,3,3,1,1,1],[1,1,1,1,1,1,1,1],[3,3,2,1],[2,1,1,1,1,2,2,1]],[[1,3,3,1],[1,3,1,1,1,1],[1,1,1,3,3],[1,1,1,1,1,1,1],[1,3,3,3],[1,1,1,1,1,1],[1,3,3,3,1],[2,1,1,1,1,1,1],[1,3,3,3],[1,1,1,1,1,1],[1,1,3,3],[1,3,1,1,1,1],[3,3,1],[1,1,2,1,3],[1,1,1,1,1,1],[3,2,2,2],[3,1,4,1],[1,1,1,2,1],[1,1,1,1,1],[2,1,3,1,1,1]],
'hard1', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[4,6,1,3,1],[1,4,3,2,4],[10,1,2],[2,6,1,1,1],[5,3,1,1,1],[4,1,1,1,2,1],[3,1,2,1,2,1],[3,1,1,1,1,1],[2,1,2,1,2],[1,1,2,5],[1,3,2],[4,7,1,1],[2,1,2,1,1,1,1],[1,1,2,2,1,2,1,1],[1,1,2,2,1,1,1,2]],[[6,3,2],[1,7,1,1],[3,4,1,1],[7,2,1],[4,1,1],[4,3,1,2],[1,3,3,1,1],[7,2],[5,1,1,1],[3,2,1,1],[1,2,1,2],[3,4],[4,2,2],[2,3,1],[4,1,1],[1,2,1,2],[2,2,1,1,1],[4,2,2],[2,4,1,1],[2,2,1,2,1]],
'hard2', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[7,3,3,2],[5,3,2,2,1],[4,2,4,1,1],[2,1,1,1,2,1],[1,2,5,5,2],[1,2,1,1,1,1,1],[1,1,2,1,1,1,1,1],[2,1,2,1,1,1,1,1],[3,2,2,1,1],[2,1,5,1,1,1],[1,6,1,1,1],[2,1,6,1,2,1,1],[1,1,5,1,1],[1,5,1,2,1,1],[1,5,1,1,1,2]],[[5,1,1,2],[4,1,2,1,1],[3,1,3,1],[3,1,2,2,1],[2,1,1,1,2],[1,1,3,1,4],[1,1,2,1,5],[1,1,1,5],[1,3,1,5],[1,1,1,4,1],[1,1,1,1,4,1],[1,1,1,4,1,1],[1,1,1,1,1,1],[5,2,1,1],[2,1,1,1,1,2],[1,1,1,1],[2,2,1,1],[3,1,1,3,1],[1,1,1,1,1,1],[6,1,3,1]],
'hard3', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,1,2,1,2,5],[1,1,1,2,1,2,4],[1,1,1,1,1,1,3],[2,1,2,1,1,2],[1,2,1,1,1,1,2],[1,5,1,2,1,1],[1,1,1,1,1,1,1],[1,1,5,1,1,1],[2,1,1,1,1,1],[1,4,2,1,1,1],[1,1,4,1,1,3,1],[2,2,1,3,1,2],[1,4,1,2,1],[7,1,1,1,1,1],[8,2,1,3,2]],[[2,3,2,3],[1,2,2,1,2],[1,1,1,1,2],[1,1,2,2,3],[2,2,1,4],[1,1,1,1,4],[1,1,1,2,3],[1,1,2,2,1],[1,3,1,2],[1,1,1,1,2,1],[1,1,1,1,1],[1,1,1,3,1],[1,1,2,2,1,1],[1,1,2,1,2],[1,2,2,1,1],[1,1,2,1,1],[2,2,2,1,1],[3,2,3,1],[5,2,2,1],[7,2,2]],
'hard4', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[2,1,1],[3,1,3,2],[6,3,6],[6,1,9],[6,9],[5,7],[2,1,7,1],[2,4,1],[1,1,3,3],[1,3,4,3],[5,5],[4,3,2],[3,2,4],[2,1,4],[1,2,1]],[[2,2],[4],[5],[7,2],[11],[5,6],[3,5],[2,1],[4],[3],[1,2],[4,4],[1,4,6],[4,5],[6,1],[8],[10,3],[8,4],[3,1,3],[2,2,3]],
'hard5', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Game(
[[2,4,1,6,1],[4,2,2,2,3],[4,2,2,4],[1,2,1,1,2,2],[3,2,2,4],[2,1,1,1,1,2],[1,1,7,1,2],[1,1,1,1,1,1],[1,3,3,3,2],[5,1,1,1,3,1],[2,1,1,5,1,1,2],[3,1,1,3,1],[1,1,1,3,1,1,1,1],[3,1,1,1,1,3,1],[1,1,1,5,1,1,1,1]],[[1,7,1],[3,2,6],[4,2,1,1,1],[4,1,7],[2,1,2],[1,4,7],[1,1,2],[1,1,2,2],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,2,2],[1,1,2],[1,4,7],[2,1,1],[4,1,7],[1,3,2,1,1,1],[3,2,6],[8,1],[2,2,1,2,4]],
'hard6', {'theme': {'filledColor': 'red','isMeshed':true}}
).solve();
new nonogram.Solver(
[[7,1,1,7],[1,1,1,1,1,1],[1,3,1,1,1,1,3,1],[1,3,1,2,1,1,3,1],[1,3,1,3,1,3,1],[1,1,3,1,1,1],[7,1,1,1,7],[3],[5,4,2,1,1,2],[2,1,1,2,2,2,1],[2,1,6,1,1],[3,1,5],[1,5,1,1,2,1],[6,6],[7,1,1,1,1,1],[1,1,1,2,2,1],[1,3,1,3,5,1],[1,3,1,2,2,2],[1,3,1,2,1,2],[1,1,1,1,3],[7,4,2,1]],[[7,3,7],[1,1,5,1,1],[1,3,1,1,1,1,3,1],[1,3,1,2,1,1,3,1],[1,3,1,1,1,1,1,3,1],[1,1,1,1,1,1],[7,1,1,1,7],[1,3],[1,1,2,1,1,3,5],[1,2,1,3,1,4,1],[4,2,1,1,2],[1,2,1,1,2,1,1,1],[1,1,6,5],[3,1,2],[7,1,1],[1,1,1,1,2,2,1],[1,3,1,1,3,2,2],[1,3,1,2,5,2],[1,3,1,1,1,1,2],[1,1,1,4,1],[7,2,1,1,2]],
'hard7', {'theme': {'filledColor': 'black','isMeshed':true}}
).solve(); */
</script>
</body>