1 && -1 === $map[$pos - $bit -1]){ $move = $pos - $bit; $map[$move -1 ] = $step +1; $queue[] = $move; } } echo $map[$n -1 ] . PHP_EOL;