Collect results from previous versions in a README.

This commit is contained in:
KtorZ
2024-07-16 17:13:03 +02:00
parent 5b0a1716b5
commit f14dab9547
3 changed files with 200 additions and 295 deletions

View File

@@ -79,7 +79,7 @@ fn done(item: (Int, ChessSet)) -> Bool {
// ------------------------------------------------------------------ Fixtures
fn solution_100_6x6() {
fn solution_100_6x6() -> Solution {
[
(
0,
@@ -268,7 +268,7 @@ fn solution_100_6x6() {
]
}
fn solution_100_8x8() {
fn solution_100_8x8() -> Solution {
[
(
0,
@@ -278,32 +278,36 @@ fn solution_100_8x8() {
start: Some((1, 1)),
visited: [
(3, 2),
(5, 3),
(4, 5),
(5, 7),
(7, 6),
(8, 8),
(6, 7),
(5, 5),
(3, 4),
(1, 5),
(2, 7),
(4, 8),
(3, 6),
(1, 7),
(3, 8),
(4, 6),
(6, 5),
(4, 4),
(5, 6),
(6, 4),
(7, 2),
(8, 5),
(7, 7),
(6, 5),
(8, 4),
(7, 2),
(5, 3),
(3, 4),
(4, 6),
(5, 8),
(6, 6),
(4, 5),
(3, 7),
(1, 8),
(2, 6),
(4, 7),
(5, 5),
(6, 3),
(5, 1),
(4, 3),
(3, 5),
(5, 4),
(7, 3),
(8, 1),
(6, 2),
(4, 1),
(2, 2),
(1, 4),
(3, 3),
(2, 5),
(1, 3),
@@ -314,31 +318,27 @@ fn solution_100_8x8() {
(7, 4),
(8, 6),
(7, 8),
(6, 6),
(8, 5),
(7, 7),
(5, 8),
(3, 7),
(1, 8),
(2, 6),
(1, 4),
(2, 2),
(4, 1),
(6, 2),
(8, 1),
(7, 3),
(5, 7),
(3, 8),
(1, 7),
(3, 6),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(5, 2),
(7, 1),
(8, 3),
(7, 5),
(8, 7),
(6, 8),
(4, 7),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(7, 6),
(8, 8),
(6, 7),
(4, 8),
(2, 7),
(1, 5),
(2, 3),
(1, 1),
],
@@ -352,32 +352,36 @@ fn solution_100_8x8() {
start: Some((1, 1)),
visited: [
(3, 2),
(5, 3),
(4, 5),
(5, 7),
(7, 6),
(8, 8),
(6, 7),
(4, 8),
(2, 7),
(1, 5),
(3, 4),
(5, 5),
(3, 6),
(1, 7),
(3, 8),
(4, 6),
(6, 5),
(4, 4),
(5, 6),
(7, 7),
(8, 5),
(6, 4),
(7, 2),
(8, 4),
(6, 5),
(5, 3),
(3, 4),
(4, 6),
(5, 8),
(6, 6),
(4, 5),
(3, 7),
(1, 8),
(2, 6),
(4, 7),
(5, 5),
(6, 3),
(5, 1),
(4, 3),
(3, 5),
(5, 4),
(7, 3),
(8, 1),
(6, 2),
(4, 1),
(2, 2),
(1, 4),
(3, 3),
(2, 5),
(1, 3),
@@ -388,184 +392,101 @@ fn solution_100_8x8() {
(7, 4),
(8, 6),
(7, 8),
(6, 6),
(8, 5),
(7, 7),
(5, 8),
(3, 7),
(1, 8),
(2, 6),
(1, 4),
(2, 2),
(4, 1),
(6, 2),
(8, 1),
(7, 3),
(5, 2),
(7, 1),
(8, 3),
(7, 5),
(8, 7),
(6, 8),
(4, 7),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(2, 3),
(1, 1),
],
},
),
]
}
fn solution_80_8x8() {
[
(
0,
ChessSet {
size: 8,
move_number: 64,
start: Some((1, 1)),
visited: [
(3, 2),
(5, 3),
(4, 5),
(5, 7),
(7, 6),
(8, 8),
(6, 7),
(5, 5),
(3, 4),
(1, 5),
(2, 7),
(4, 8),
(3, 6),
(1, 7),
(3, 8),
(4, 6),
(6, 5),
(4, 4),
(5, 6),
(6, 4),
(7, 2),
(8, 4),
(6, 3),
(5, 1),
(4, 3),
(3, 5),
(5, 4),
(3, 3),
(2, 5),
(1, 3),
(2, 1),
(4, 2),
(6, 1),
(8, 2),
(7, 4),
(8, 6),
(7, 8),
(6, 6),
(8, 5),
(7, 7),
(5, 8),
(3, 7),
(1, 8),
(2, 6),
(1, 4),
(2, 2),
(4, 1),
(6, 2),
(8, 1),
(7, 3),
(5, 2),
(7, 1),
(8, 3),
(7, 5),
(8, 7),
(6, 8),
(4, 7),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(2, 3),
(1, 1),
],
},
),
(
0,
ChessSet {
size: 8,
move_number: 64,
start: Some((1, 1)),
visited: [
(3, 2),
(5, 3),
(4, 5),
(5, 7),
(7, 6),
(8, 8),
(6, 7),
(4, 8),
(2, 7),
(1, 5),
(3, 4),
(5, 5),
(3, 6),
(1, 7),
(3, 8),
(4, 6),
(6, 5),
(4, 4),
(5, 6),
(6, 4),
(7, 2),
(8, 4),
(6, 3),
(5, 1),
(4, 3),
(3, 5),
(5, 4),
(3, 3),
(2, 5),
(1, 3),
(2, 1),
(4, 2),
(6, 1),
(8, 2),
(7, 4),
(8, 6),
(7, 8),
(6, 6),
(8, 5),
(7, 7),
(5, 8),
(3, 7),
(1, 8),
(2, 6),
(1, 4),
(2, 2),
(4, 1),
(6, 2),
(8, 1),
(7, 3),
(5, 7),
(3, 8),
(1, 7),
(3, 6),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(5, 2),
(7, 1),
(8, 3),
(7, 5),
(8, 7),
(6, 8),
(7, 6),
(8, 8),
(6, 7),
(4, 8),
(2, 7),
(1, 5),
(2, 3),
(1, 1),
],
},
),
(
0,
ChessSet {
size: 8,
move_number: 64,
start: Some((1, 1)),
visited: [
(3, 2),
(4, 4),
(6, 5),
(8, 4),
(7, 2),
(5, 3),
(3, 4),
(4, 6),
(5, 8),
(7, 7),
(5, 6),
(6, 4),
(8, 5),
(6, 6),
(4, 5),
(3, 7),
(1, 8),
(2, 6),
(4, 7),
(5, 5),
(6, 3),
(5, 1),
(4, 3),
(3, 5),
(5, 4),
(7, 3),
(8, 1),
(6, 2),
(4, 1),
(2, 2),
(1, 4),
(3, 3),
(2, 5),
(1, 3),
(2, 1),
(4, 2),
(6, 1),
(8, 2),
(7, 4),
(8, 6),
(7, 8),
(5, 7),
(3, 8),
(1, 7),
(3, 6),
(2, 8),
(1, 6),
(2, 4),
(1, 2),
(3, 1),
(5, 2),
(7, 1),
(8, 3),
(7, 5),
(8, 7),
(6, 8),
(7, 6),
(8, 8),
(6, 7),
(4, 8),
(2, 7),
(1, 5),
(2, 3),
(1, 1),
],

View File

@@ -133,11 +133,11 @@ fn possible_moves(board: ChessSet) -> List<Direction> {
direction_list() |> list.filter(can_move(board, _))
}
fn compare_tile(a: Tile, b: Tile) -> Ordering {
if a.1st == b.1st {
int.compare(a.2nd, b.2nd)
} else {
fn compare_chess_set(a: (Int, ChessSet), b: (Int, ChessSet)) -> Ordering {
if a.1st != b.1st {
int.compare(a.1st, b.1st)
} else {
compare_list(a.2nd.visited, b.2nd.visited)
}
}
@@ -163,37 +163,10 @@ fn compare_list(xs: List<Tile>, ys: List<Tile>) -> Ordering {
}
}
fn compare_chess_set(a: (Int, ChessSet), b: (Int, ChessSet)) -> Ordering {
if a.1st != b.1st {
int.compare(a.1st, b.1st)
fn compare_tile(a: Tile, b: Tile) -> Ordering {
if a.1st == b.1st {
int.compare(a.2nd, b.2nd)
} else {
let ChessSet {
size: size_a,
move_number: move_a,
start: start_a,
visited: visited_a,
} = a.2nd
let ChessSet {
size: size_b,
move_number: move_b,
start: start_b,
visited: visited_b,
} = b.2nd
if size_a != size_b {
int.compare(size_a, size_b)
} else if move_a != move_b {
int.compare(move_a, move_b)
} else if start_a != start_b {
when start_a is {
Some(a) ->
when start_b is {
Some(b) -> compare_tile(a, b)
None -> Greater
}
None -> Less
}
} else {
compare_list(visited_a, visited_b)
}
int.compare(a.1st, b.1st)
}
}