aboutsummaryrefslogtreecommitdiff
path: root/challenge-281/conor-hoekstra/ch-2.bqn
blob: 4289be1dab049d70ceb6435bd89da108e722506f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# For up to date code:
# https://github.com/codereport/bqn-code/blob/main/pwc/281-2.bqn

Convert  48|-'0'¨
deltas   (¨)∾<˘2¯21¯1
IsValid  ´1≤∧8
Moves    {IsValid¨/⥊𝕩+deltas}

MinKnightMoves  {
    endstart  𝕨 Convert 𝕩
    1 end { ´𝕗¨Moves 𝕩 ? 𝕨 ; (𝕨+1) 𝕊 Moves 𝕩 } start
}

# Tests
•Show "g2" MinKnightMoves "a8" # 4
•Show "g2" MinKnightMoves "h2" # 3