Even from the outside the inn looked a pleasant home to familiar eyes. A sign above the door pictured a fat white pony rearing on its hind legs. Over the door was painted the letters: _THE PRANCING PONY by BARLIMAN BUTTERBALL_.
Prancing Pony is a simple implementation of the Knight's Tour using the backtracking strategy for variable board sizes and variable starting positions. It is guaranteed to find a solution and will know immediately if the given parameters have no possible Tour.
Because this is a brute force and naive O(n!) solution, it should NOT be expected to find a result in the given parameters in most configurations, however it should behave well for small boards (less than 40 squares) or traditional boards with 8x8 size starting at position (0,0).
``` let tourinput = prancingpony::TourInput { sizex: 8, sizey: 8, starting_position: (0,0) };
let result = prancingpony::findsolution(tour_input);
match result { prancingpony::TourResult::Solution(t) => { println!("Solution found in {} nanoseconds after {} backtracks", t.calculationtime, t.timesbacktracked); for (index, position) in t.positionhistory.iter().enumerate() { println!("{} - ({} {})", index, position.0, position.1); } }, prancingpony::TourResult::NoSolution => { println!("No Solution"); }, prancingpony::TourResult::InvalidParameters => { println!("Invalid Parameters"); } } ```