inelegant python brute force solution
def parse(s): return (ord(s[0]) - ord('a'), int(s[1])) def move(start, end): return move_inner({parse(start)}, parse(end)) def next_moves(positions): moves = set() for move in positions: for position in get_moves(move): if ( position[0] >= 0 and position[1] >= 0 and position[0] < 8 and position[1] < 8 ): moves.add(position) return moves def move_inner(from_start, end, n=1): print(from_start) nstart = from_start | next_moves(from_start) if end in nstart: return n else: return move_inner(nstart, end, n + 1) def get_moves(point): (x, y) = point return [ (x + 2, y + 1), (x + 2, y - 1), (x - 2, y + 1), (x - 2, y - 1), (x + 1, y + 2), (x + 1, y - 2), (x - 1, y + 2), (x - 1, y - 2), ]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
inelegant python brute force solution