Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Chess Knight by Tinus_Trotyl
def chess_knight(start, moves):
mv = ((-1, -2), (1, -2), (-2, -1), (2, -1), (-2, 1), (2, 1), (-1, 2), (1, 2))
mvs = [(ord(start[1]) - 49, ord(start[0]) - 97)]
for _ in range(moves):
for x, y in mvs:
mvs = mvs + [(x + dx, y + dy) for dx, dy in mv if 0 <= x + dx < 8 and 0 <= y + dy < 8]
return sorted(list(set(chr(97 + y) + chr(49 + x) for x, y in mvs[1:])))
April 24, 2018
Comments: