ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2024 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.P91

Description

Some solutions to Problems.P91 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

knightsTour :: Int -> (Int, Int) -> Maybe [(Int, Int)] Source #

Returns a knight's tour ending at a particular square. Represents the squares by their coordinates with the tuple \((x,y)\), where \(1 \leq x \leq N\) and \(1 \leq y \leq N\). A tour will be a list of these tuples of length \(N \times N\).

closedKnightsTour :: Int -> Maybe [(Int, Int)] Source #

The same as knightsTour, except return a circular tour. I.e., the knight must be able to jump from the last position in the tour to the first position in the tour. Starts the tour from \((1,1)\).