Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
lookup solution in Speedy category for The Shortest Knight's Path by dabuek
import re
def checkio(cells):
table = [[0,3,2,3,2,3,4,5],
[2,1,2,3,4,3,4],
[4,3,2,3,4,5],
[2,3,4,3,4],
[4,3,4,5],
[4,5,4],
[4,5],
[6]]
if re.search('[ah][18]', cells):
table[1][0] = 4
sf, sr, _, ef, er = [ord(x) for x in cells]
x, y = abs(sf - ef), abs(sr - er)
x, y = min(x, y), max(x, y)
return table[x][y-x]
May 29, 2014
Comments: