forked from dlbeer/cdok
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
154 lines (125 loc) · 7.12 KB
/
README
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
Cdok
====
Calcudoku is a sudoku-like game invented by Tetsuya Miyamoto (marketed
under the trademarked name "KenKen"). The following is an example of a
6x6 calcudoku puzzle:
╔═════╦═════╦═════╦═════╦═══════════╗
║12+ ║4/ ║ ║ ║3* ┊ ║
║ ║ ║ 5 ║ 2 ║ ┊ ║
║ ║ ║ ║ ║ ┊ ║
║┈┈┈┈┈║┈┈┈┈┈╠═════╩═════╬═══════════╣
║ ║ ║7+ ┊ ║60* ┊ ║
║ ║ ║ ┊ ║ ┊ ║
║ ║ ║ ┊ ║ ┊ ║
║┈┈┈┈┈╠═════╬═══════════╩═════╗┈┈┈┈┈║
║ ║12+ ║28+ ┊ ┊ ║ ║
║ ║ ║ ┊ ┊ ║ ║
║ ║ ║ ┊ ┊ ║ ║
╠═════╣┈┈┈┈┈╠═══════════╗┈┈┈┈┈╚═════╣
║ ║ ║1- ┊ ║ ┊ ║
║ 3 ║ ║ ┊ ║ ┊ ║
║ ║ ║ ┊ ║ ┊ ║
╠═════╣┈┈┈┈┈╚═════╦═════╣┈┈┈┈┈╔═════╣
║ ║ ┊ ║11+ ║ ║2* ║
║ 4 ║ ┊ ║ ║ ║ ║
║ ║ ┊ ║ ║ ║ ║
╠═════╩═══════════╣┈┈┈┈┈╠═════╣┈┈┈┈┈║
║10+ ┊ ┊ ║ ║ ║ ║
║ ┊ ┊ ║ ║ 4 ║ ║
║ ┊ ┊ ║ ║ ║ ║
╚═════════════════╩═════╩═════╩═════╝
As in sudoku, each row and each column must contain the numbers 1 to 6
once each. Some initial values may be given. There are no sub-boxes,
but groups of connected cells outlined in double-lines contain a clue
in the top-left corner (e.g. "11+"). The clue consists of a target
value and one of the characters +, -, * or /, indicating the type of
the group:
Sum: +
~ The numbers in this group must add to the target value.
Difference: -
~ One of the numbers in this group, minus the rest, must equal the
target value (the number to be subtracted from may be any of the
cells).
Product: *
~ The numbers in this group must multiply to produce the target value.
Ratio: /
~ One of the numbers in this group, divided by all of the others,
must equal the target value. As in a difference group, which of
the cells contains the number to be divided is not specified.
Numbers may be repeated within a group (so long as they're not also
repeated within a row or column). Each puzzle has a unique
solution. The solution to the example shown above is:
╔═════╦═════╦═════╦═════╦═══════════╗
║12+ ║4/ ║ ║ ║3* ┊ ║
║ 6 ║ 4 ║ 5 ║ 2 ║ 1 ┊ 3 ║
║ ║ ║ ║ ║ ┊ ║
║┈┈┈┈┈║┈┈┈┈┈╠═════╩═════╬═══════════╣
║ ║ ║7+ ┊ ║60* ┊ ║
║ 5 ║ 1 ║ 4 ┊ 3 ║ 2 ┊ 6 ║
║ ║ ║ ┊ ║ ┊ ║
║┈┈┈┈┈╠═════╬═══════════╩═════╗┈┈┈┈┈║
║ ║12+ ║28+ ┊ ┊ ║ ║
║ 1 ║ 2 ║ 6 ┊ 4 ┊ 3 ║ 5 ║
║ ║ ║ ┊ ┊ ║ ║
╠═════╣┈┈┈┈┈╠═══════════╗┈┈┈┈┈╚═════╣
║ ║ ║1- ┊ ║ ┊ ║
║ 3 ║ 6 ║ 2 ┊ 1 ║ 5 ┊ 4 ║
║ ║ ║ ┊ ║ ┊ ║
╠═════╣┈┈┈┈┈╚═════╦═════╣┈┈┈┈┈╔═════╣
║ ║ ┊ ║11+ ║ ║2* ║
║ 4 ║ 3 ┊ 1 ║ 5 ║ 6 ║ 2 ║
║ ║ ┊ ║ ║ ║ ║
╠═════╩═══════════╣┈┈┈┈┈╠═════╣┈┈┈┈┈║
║10+ ┊ ┊ ║ ║ ║ ║
║ 2 ┊ 5 ┊ 3 ║ 6 ║ 4 ║ 1 ║
║ ┊ ┊ ║ ║ ║ ║
╚═════════════════╩═════╩═════╩═════╝
This program, cdok, can be used to examine, print, solve and generate
these puzzles. Puzzles are parsed in a "puzzle spec" format, where
rows are given one per line, with cells separated by spaces. Groups
are labelled with alphabetic characters, which are then used to
identify cell membership. A valid puzzle spec for the example above
is:
J+12 F/4 5 2 E*3 E
J F H+7 H I*60 I
J D+12 G+28 G G I
3 D K-1 K G G
4 D D B+11 G A*2
C+10 C C B 4 A
Puzzle specs may be terminated by a blank line. Anything following the
blank line is ignored when parsing.
Nylimb Mode
-----------
Paul Falstad and Rick Richardson did "Nylimb Mode", which is described here:
https://coord.info/GC7WQR5
Just use -N on the command line.
Installation
------------
To build cdok, type ``make``. Type ``make install`` to install the
resulting binary.
Try it out by typing ``cdok generate`` to generate a 6x6 puzzle. If
your terminal supports UTF-8, use the ``-u`` flag to draw the puzzle
using UTF-8 line-drawing characters.
Some definitions of Calcudoku require that difference and ratio groups
be limited to two cells (to avoid confusion due to the
non-associativity of subtraction and division). Cdok does not impose
this requirement in generated puzzles by default, but it will if you
use the ``-T`` option.
Type ``cdok --help`` to get a full list of options.
Copyright
---------
Copyright (C) 2012 Daniel Beer <dlbeer@gmail.com>
Copyright (C) 2018 Paul Falslad <paul@falstad.com>
Copyright (C) 2018 Rick Richardson <rickrich@gmail.com>
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all
copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.