Skip to main content
1 of 2
Kjetil S
  • 6.1k
  • 10
  • 22

Perl 5, 166 bytes

sub{($s,$e,%o)=@_;@w=(0,$s);while(($n,$s,@w)=@w){$s-$e||last,push@w,map{$n+1,$_}grep{($a,$b,$c,$d)=map{$_>>3,$_%8}$s,$_;!(($a-$c)**2+($b-$d)**2-5||$o{$_}++)}0..63}$n}

Try it online!

Kjetil S
  • 6.1k
  • 10
  • 22