Permalink
Browse files

Cleaner SPOILER handling

  • Loading branch information...
1 parent 043173b commit a2fef06618e3ae522f3998b77bac014fd4508f80 @ekmett committed Mar 19, 2013
Showing with 63 additions and 2 deletions.
  1. +1 −1 Setup.lhs
  2. +54 −1 ersatz.cabal
  3. +8 −0 notes/{regexp-grid-spoiler.txt → SPOILER.html}
  4. BIN notes/grid.pdf
View
2 Setup.lhs
@@ -22,7 +22,7 @@ main = defaultMainWithHooks simpleUserHooks
generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
buildHook simpleUserHooks pkg lbi hooks flags
, postHaddock = \args flags pkg lbi -> do
- copyFiles normal (haddockOutputDir flags pkg) [("notes","regexp-grid-spoiler.txt")]
+ copyFiles normal (haddockOutputDir flags pkg) [("notes","SPOILER.html"), ("notes","grid.pdf")]
postHaddock simpleUserHooks args flags pkg lbi
}
View
55 ersatz.cabal
@@ -20,6 +20,58 @@ description: A monad for expressing SAT or QSAT problems using observable sha
.
> half_adder :: Bit -> Bit -> (Bit, Bit)
> half_adder a b = (a `xor` b, a && b)
+ .
+ * Longer Examples
+ .
+ Included are a couple of examples included with the distribution.
+ Neither are as fast as a dedicated solver for their respective
+ domains, but they showcase how you can solve real world problems
+ involving 10s or 100s of thousands of variables and constraints
+ with `ersatz`.
+ .
+ @ersatz-sudoku@
+ .
+ > % time ersatz-sudoku
+ > Problem:
+ > ┌───────┬───────┬───────┐
+ > │ 5 3 │ 7 │ │
+ > │ 6 │ 1 9 5 │ │
+ > │ 9 8 │ │ 6 │
+ > ├───────┼───────┼───────┤
+ > │ 8 │ 6 │ 3 │
+ > │ 4 │ 8 3 │ 1 │
+ > │ 7 │ 2 │ 6 │
+ > ├───────┼───────┼───────┤
+ > │ 6 │ │ 2 8 │
+ > │ │ 4 1 9 │ 5 │
+ > │ │ 8 │ 7 9 │
+ > └───────┴───────┴───────┘
+ > Solution:
+ > ┌───────┬───────┬───────┐
+ > │ 5 3 4 │ 6 7 8 │ 9 1 2 │
+ > │ 6 7 2 │ 1 9 5 │ 3 4 8 │
+ > │ 1 9 8 │ 3 4 2 │ 5 6 7 │
+ > ├───────┼───────┼───────┤
+ > │ 8 5 9 │ 7 6 1 │ 4 2 3 │
+ > │ 4 2 6 │ 8 5 3 │ 7 9 1 │
+ > │ 7 1 3 │ 9 2 4 │ 8 5 6 │
+ > ├───────┼───────┼───────┤
+ > │ 9 6 1 │ 5 3 7 │ 2 8 4 │
+ > │ 2 8 7 │ 4 1 9 │ 6 3 5 │
+ > │ 3 4 5 │ 2 8 6 │ 1 7 9 │
+ > └───────┴───────┴───────┘
+ > ersatz-sudoku 1,13s user 0,04s system 99% cpu 1,179 total
+ .
+ @ersatz-regexp-grid@
+ .
+ This solves the \"regular crossword puzzle\" (<grid.pdf>) from the 2013 MIT mystery hunt.
+ .
+ > % time ersatz-regexp-grid
+ .
+ "SPOILER"
+ .
+ > ersatz-regexp-grid 2,45s user 0,05s system 99% cpu 2,502 total
+
copyright: © 2010-2013 Edward Kmett, © 2013 Johan Kiviniemi
build-type: Custom
cabal-version: >= 1.10
@@ -37,8 +89,9 @@ extra-source-files:
examples/sudoku/COPYING
examples/sudoku/Setup.hs
examples/sudoku/sudoku.cabal
+ notes/grid.pdf
notes/papers.md
- notes/regexp-grid-spoiler.txt
+ notes/SPOILER.html
travis/cabal-apt-install
travis/config
View
8 notes/regexp-grid-spoiler.txt → notes/SPOILER.html
@@ -1,3 +1,8 @@
+<html>
+<head><title>Spoiler for regexp-grid</title></head>
+</head>
+<body>
+<pre>
N H P E H A S
D I O M O M T H
F O X N X A X P H
@@ -11,3 +16,6 @@
N C X D X E X L E
R R D D M M M M
G C C H H C C
+</pre>
+</body>
+</html>
View
BIN notes/grid.pdf
Binary file not shown.

0 comments on commit a2fef06

Please sign in to comment.