Skip to content

Given a chess board setup up with initial knight position and destination, it finds the shortest path (minimum number of steps) for the knight to another position (destination) on the board.

Notifications You must be signed in to change notification settings

kanmaniselvan/shortest_knight_moves

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shortest Knight moves

Given a board setup up with initial knight position and destination, it finds the shortest path (minimum number of steps) for the knight to another position (destination) on the board.

Setup

$ bundle install
$ rails s

* All responses from the app are JSON encoded

Run

url: <app_url>/chess_boards
method: POST
params: { knight_position: 'H1'}

You will get board_id as response. With that board_id call,

url: <app_url>/knights/get_shortest_path
method: GET
params: { board_id: '<board_id>', destination: 'G2' }

The response will contain the shortest_path.

Test

$ rpsec

About

Given a chess board setup up with initial knight position and destination, it finds the shortest path (minimum number of steps) for the knight to another position (destination) on the board.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published