pub fn generate_puzzle(
n: usize,
minimum_removals: usize,
random: bool,
) -> Puzzle
Expand description
Generates a puzzle with a valid Eulerian cycle and removes a specified number of tiles.
This function constructs a Graph
representation of the puzzle, finds an Eulerian cycle,
and converts the cycle into a Solution
. Then, it removes a specified number of tiles
either sequentially or randomly, based on the random
flag.
§Arguments
n
- The size of the puzzle.minimum_removals
- The number of tiles to remove from the solution.random
- Iftrue
, removes tiles at random; otherwise, removes them sequentially.
§Returns
A Puzzle
instance with Some(Tile)
values for placed tiles and None
for removed tiles.