Skip to content

Instantly share code, notes, and snippets.

@Feni
Feni / gist:d819f120a7d179bc472c94df9471e600
Last active February 20, 2021 17:26
Knight's tour example
// Knight's tour: Find the sequence of moves of a knight on a chessboard such that the knight visits every square exactly once.
// A move is an array of 2 numbers indicating how many [rows, columns] a piece travels.
type Move: [Integer, 2]
// <static type> identifier : (<dependent types>) = <value>
let knightMoves: [Move] = [[2, 1], [1, 2], [-1, 2], [-2, 1], [-2, -1], [-1, -2], [1, -2], [2, -1]]
// A Position is a 2 element array indicating [row, column] index (in range 0 to 8) on the board.
type Position: [Integer 0...8, 2]
arr: [1, 15, 21, 9, 12, 28, 42, 23, 100]
# Index array
arr[3]
# Map
days:
0: “Monday”
1: “Tuesday”
2: “Wednesday”
### Keybase proof
I hereby claim:
* I am feni on github.
* I am feni (https://keybase.io/feni) on keybase.
* I have a public key ASBI-xuT1RqzJbuXfOD3bdWAQs7r99CqEBe-YnmufccwRgo
To claim this, I am signing this object: