/knight_moves

Calculate the shortest path for a Chess Knight to an arbitrary position. Timed exercise, 30m.

Primary LanguageRuby

Problem

Calculate the shortest path for a Chess Knight to an arbitrary position A,B on an infinitely large chessboard.

The knight starts at 0,0 and can go in any direction.

The knight can only move as a knight moves in Chess.

The solution should be as efficient as possible.

Solve in 30m or less!

Running

Simply run with:

ruby knight_moves.rb