Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleaner SPOILER handling

  • Loading branch information...
commit a2fef06618e3ae522f3998b77bac014fd4508f80 1 parent 043173b
Edward Kmett authored
2  Setup.lhs
@@ -22,7 +22,7 @@ main = defaultMainWithHooks simpleUserHooks
22 22 generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
23 23 buildHook simpleUserHooks pkg lbi hooks flags
24 24 , postHaddock = \args flags pkg lbi -> do
25   - copyFiles normal (haddockOutputDir flags pkg) [("notes","regexp-grid-spoiler.txt")]
  25 + copyFiles normal (haddockOutputDir flags pkg) [("notes","SPOILER.html"), ("notes","grid.pdf")]
26 26 postHaddock simpleUserHooks args flags pkg lbi
27 27 }
28 28
55 ersatz.cabal
@@ -20,6 +20,58 @@ description: A monad for expressing SAT or QSAT problems using observable sha
20 20 .
21 21 > half_adder :: Bit -> Bit -> (Bit, Bit)
22 22 > half_adder a b = (a `xor` b, a && b)
  23 + .
  24 + * Longer Examples
  25 + .
  26 + Included are a couple of examples included with the distribution.
  27 + Neither are as fast as a dedicated solver for their respective
  28 + domains, but they showcase how you can solve real world problems
  29 + involving 10s or 100s of thousands of variables and constraints
  30 + with `ersatz`.
  31 + .
  32 + @ersatz-sudoku@
  33 + .
  34 + > % time ersatz-sudoku
  35 + > Problem:
  36 + > ┌───────┬───────┬───────┐
  37 + > │ 5 3 │ 7 │ │
  38 + > │ 6 │ 1 9 5 │ │
  39 + > │ 9 8 │ │ 6 │
  40 + > ├───────┼───────┼───────┤
  41 + > │ 8 │ 6 │ 3 │
  42 + > │ 4 │ 8 3 │ 1 │
  43 + > │ 7 │ 2 │ 6 │
  44 + > ├───────┼───────┼───────┤
  45 + > │ 6 │ │ 2 8 │
  46 + > │ │ 4 1 9 │ 5 │
  47 + > │ │ 8 │ 7 9 │
  48 + > └───────┴───────┴───────┘
  49 + > Solution:
  50 + > ┌───────┬───────┬───────┐
  51 + > │ 5 3 4 │ 6 7 8 │ 9 1 2 │
  52 + > │ 6 7 2 │ 1 9 5 │ 3 4 8 │
  53 + > │ 1 9 8 │ 3 4 2 │ 5 6 7 │
  54 + > ├───────┼───────┼───────┤
  55 + > │ 8 5 9 │ 7 6 1 │ 4 2 3 │
  56 + > │ 4 2 6 │ 8 5 3 │ 7 9 1 │
  57 + > │ 7 1 3 │ 9 2 4 │ 8 5 6 │
  58 + > ├───────┼───────┼───────┤
  59 + > │ 9 6 1 │ 5 3 7 │ 2 8 4 │
  60 + > │ 2 8 7 │ 4 1 9 │ 6 3 5 │
  61 + > │ 3 4 5 │ 2 8 6 │ 1 7 9 │
  62 + > └───────┴───────┴───────┘
  63 + > ersatz-sudoku 1,13s user 0,04s system 99% cpu 1,179 total
  64 + .
  65 + @ersatz-regexp-grid@
  66 + .
  67 + This solves the \"regular crossword puzzle\" (<grid.pdf>) from the 2013 MIT mystery hunt.
  68 + .
  69 + > % time ersatz-regexp-grid
  70 + .
  71 + "SPOILER"
  72 + .
  73 + > ersatz-regexp-grid 2,45s user 0,05s system 99% cpu 2,502 total
  74 +
23 75 copyright: © 2010-2013 Edward Kmett, © 2013 Johan Kiviniemi
24 76 build-type: Custom
25 77 cabal-version: >= 1.10
@@ -37,8 +89,9 @@ extra-source-files:
37 89 examples/sudoku/COPYING
38 90 examples/sudoku/Setup.hs
39 91 examples/sudoku/sudoku.cabal
  92 + notes/grid.pdf
40 93 notes/papers.md
41   - notes/regexp-grid-spoiler.txt
  94 + notes/SPOILER.html
42 95 travis/cabal-apt-install
43 96 travis/config
44 97
8 notes/regexp-grid-spoiler.txt → notes/SPOILER.html
... ... @@ -1,3 +1,8 @@
  1 +<html>
  2 +<head><title>Spoiler for regexp-grid</title></head>
  3 +</head>
  4 +<body>
  5 +<pre>
1 6 N H P E H A S
2 7 D I O M O M T H
3 8 F O X N X A X P H
@@ -11,3 +16,6 @@
11 16 N C X D X E X L E
12 17 R R D D M M M M
13 18 G C C H H C C
  19 +</pre>
  20 +</body>
  21 +</html>
BIN  notes/grid.pdf
Binary file not shown

0 comments on commit a2fef06

Please sign in to comment.
Something went wrong with that request. Please try again.