Copyright | Copyright (C) 2021 Yoo Chung |
---|---|
License | GPL-3.0-or-later |
Maintainer | dev@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Supporting definitions for crossword puzzles. In particular, this supports Problems.P99.
Documentation
A crossword puzzle.
A list of words to fill the puzzle with is given along the grid to fill. The crossword puzzle grid is represented with a list of sublists. Each sublist denotes a row, and each value in the sublists denotes a spot. For each value in a spot:
Instances
printCrossword :: Maybe [[Maybe Char]] -> IO () Source #
Print out a solution to a crossword puzzle.
>>>
:{
printCrossword $ Just [ [ Nothing, Nothing, Just 'P', Nothing, Nothing ] , [ Nothing, Nothing, Just 'O', Nothing, Nothing ] , [ Just 'A', Just 'L', Just 'P', Just 'H', Just 'A' ] , [ Nothing, Nothing, Just 'P', Nothing, Just 'R' ] , [ Nothing, Nothing, Just 'Y', Nothing, Just 'E' ] , [ Nothing, Nothing, Nothing, Nothing, Just 'S' ] ] :} ■ ■ P ■ ■ ■ ■ O ■ ■ A L P H A ■ ■ P ■ R ■ ■ Y ■ E ■ ■ ■ ■ S
parseCrossword :: String -> Maybe Crossword Source #
Parses a crossword puzzle specification in a particular syntax.
It first lists the words in an arbitrary order, one word per line.
Then, after an empty line, the crossword grid is defined.
In this grid specification, a blank spot is represented by a dot (.
).
Spots can also contain predefined character values.
Notes
This parses the crossword specifications provided by problem 99 in the original list.
readCrossword :: FilePath -> IO (Maybe Crossword) Source #
Reads a crossword puzzle from a file, whose syntax is as specified by parseCrossword
.
Notes
This parses the crossword specifications provided by problem 99 in the original list.