我已经为NQueen问题编写了解决方案。它也有效,但它在最后一步得到了例外。
这是我写的
let isNotDiagonal p c =
System.Math.Abs((int)((fst c) - (fst p))) <> System.Math.Abs((int)((snd c) - (snd p)));;
let isAllowed c = function
| [] -> true
| list -> List.forall (fun p -> (fst c) <> (fst p) && (snd c) <> (snd p) && (isNotDiagonal p c)) list;;
let comparePoints p1 p2 =
match p1, p2 with
| p1, p2 when (fst p1 > fst p2) -> 1
| p1, p2 when (fst p1 < fst p2) -> -1
| p1, p2 when (fst p1 = fst p2) && (snd p1 > snd p2)-> 1
| p1, p2 when (fst p1 = fst p2) && (snd p1 < snd p2) -> -1
| p1, p2 when (fst p1 = fst p2) && (snd p1 = snd p2) -> 0
| _, _ -> failwith "unknown pattern";;
let sort_list list =
List.sortWith comparePoints list;;
let print_list list =
printfn "%s" (List.fold (fun acc p -> acc + "(" + (fst p).ToString() + ", " + (snd p).ToString() + ")") "" (sort_list list));;
let rec moveQueen board pos list =
match pos with
| (row, col) when row < board && col < board ->
if isAllowed pos list then
moveQueen board (0, col + 1) (pos :: list)
else
moveQueen board (row + 1, col) (list)
| (row, col) when row >= board && col < board ->
moveQueen board (fst (List.head list) + 1, (snd (List.head list))) (List.tail list)
| (row, col) when col >= board ->
print_list list
moveQueen board (fst (List.head list) + 1, (snd (List.head list))) (List.tail list)
()
| (_, _) -> failwith "unknown combination";;
moveQueen 8 (0, 0) [];;
我得到以下输出
> (0, 0)(1, 6)(2, 4)(3, 7)(4, 1)(5, 3)(6, 5)(7, 2)
(0, 0)(1, 6)(2, 3)(3, 5)(4, 7)(5, 1)(6, 4)(7, 2)
(0, 0)(1, 5)(2, 7)(3, 2)(4, 6)(5, 3)(6, 1)(7, 4)
(0, 0)(1, 4)(2, 7)(3, 5)(4, 2)(5, 6)(6, 1)(7, 3)
(0, 5)(1, 0)(2, 4)(3, 1)(4, 7)(5, 2)(6, 6)(7, 3)
(0, 3)(1, 0)(2, 4)(3, 7)(4, 1)(5, 6)(6, 2)(7, 5)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2)(5, 7)(6, 5)(7, 0)
(0, 2)(1, 4)(2, 1)(3, 7)(4, 5)(5, 3)(6, 6)(7, 0)
(0, 2)(1, 5)(2, 3)(3, 1)(4, 7)(5, 4)(6, 6)(7, 0)
System.ArgumentException: The input list was empty.
Parameter name: list
at Microsoft.FSharp.Collections.ListModule.Head[T](FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at FSI_0020.moveQueen(Int32 board, Int32 pos_0, Int32 pos_1, FSharpList`1 list)
at <StartupCode$FSI_0021>.$FSI_0021.main@()
at main@dm()
Stopped due to error
我无法理解为什么我会得到例外。
另外,如何返回列表清单?哪个列表是解决方案?
排序和比较方法背后的目标是,我应该能够消除重复的解决方案,并且能够找到适用于各种电路板尺寸的独特解决方案。
答案 0 :(得分:2)
你得到异常,因为你在空列表中使用List.head,但这不是真正的问题,问题是moveQueen没有结束条件。
你必须注意找到所有解决方案后发生的事情,在你的代码中它会尝试获得空列表的头部并失败。
一种方法(我没有测试那么多)是:
let rec moveQueen board pos list : (int * int) list list =
match pos with
| (row, col) when row < board && col < board ->
if isAllowed pos list then
moveQueen board (0, col + 1) (pos :: list)
else
moveQueen board (row + 1, col) (list)
| (row, _) when row >= board && List.isEmpty list -> []
| (row, col) when row >= board && col < board ->
moveQueen board (fst (List.head list) + 1, (snd (List.head list))) (List.tail list)
| (_, col) when col >= board ->
list::moveQueen board (fst (List.head list) + 1, (snd (List.head list))) (List.tail list)
| (row, col) -> failwith ("unknown combination (" + row.ToString() + ", " + col.ToString() + ")");;
List.iter print_list (moveQueen 8 (0, 0) []);;