aboutsummaryrefslogtreecommitdiff
path: root/latin.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2010-01-11 21:21:07 +0000
committerSimon Tatham <anakin@pobox.com>2010-01-11 21:21:07 +0000
commit58e0d0bc2da319fb77f1337211ef6ef651f851f0 (patch)
treee070345ed1569c66c31cebcc0dd001234e46d544 /latin.c
parent771f5446a8c81584bc2d700e0f991eb727b85b9e (diff)
downloadpuzzles-58e0d0bc2da319fb77f1337211ef6ef651f851f0.zip
puzzles-58e0d0bc2da319fb77f1337211ef6ef651f851f0.tar.gz
puzzles-58e0d0bc2da319fb77f1337211ef6ef651f851f0.tar.bz2
puzzles-58e0d0bc2da319fb77f1337211ef6ef651f851f0.tar.xz
New puzzle from James Harvey: 'Singles', an implementation of
Hitori. One infrastructure change in the process: latin.c has acquired a utility function to generate a latin rectangle rather than a full square. [originally from svn r8828]
Diffstat (limited to 'latin.c')
-rw-r--r--latin.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/latin.c b/latin.c
index 63f96a1..03d78af 100644
--- a/latin.c
+++ b/latin.c
@@ -1236,6 +1236,24 @@ digit *latin_generate(int o, random_state *rs)
return sq;
}
+digit *latin_generate_rect(int w, int h, random_state *rs)
+{
+ int o = max(w, h), x, y;
+ digit *latin, *latin_rect;
+
+ latin = latin_generate(o, rs);
+ latin_rect = snewn(w*h, digit);
+
+ for (x = 0; x < w; x++) {
+ for (y = 0; y < h; y++) {
+ latin_rect[y*w + x] = latin[y*o + x];
+ }
+ }
+
+ sfree(latin);
+ return latin_rect;
+}
+
/* --------------------------------------------------------
* Checking.
*/