Computer Science Canada Programming Problem - Knight Move! |
Author: | MysticVegeta [ Thu Oct 20, 2005 2:01 pm ] | ||
Post subject: | Programming Problem - Knight Move! | ||
PS: This problem is made by me! No I dont know the solution. All Languages welcome. A grid (x, y) represents the size of the chess board. A Knight is a piece of the chess board that only moves 21/2 steps. For Example, x marks the points where the knight moves. '0' represents his position
A knight when placed in the centre of a 8 X 8 board moves in 8 directions 1) 2 steps up and 1 right 2) 2 steps up and 1 left 3) 2 steps down and 1 right 4) 2 steps down and 1 left 5) 1 step left and 2 up 6) 1 step left and 2 down 7) 1 step right and 2 up 8) 1 step right and 2 down Your job is to calculate the minimum number of moves requried for the Knight to complete his travel on all the squares. Input: The first line will contain the X coordinate, Y coordinate where x, y >= 4, x = y. separated by commas Output : The minimum number of moves required for the knight to complete his travel Sample Input 4, 4 8, 8 Any programming language is available Problem copyright by me |
Author: | Mazer [ Thu Oct 20, 2005 4:58 pm ] |
Post subject: | |
What's the second line? And why bother listing x and y if, as you said, x = y? Also, this should probably be in the contests section. |
Author: | Blade [ Fri Oct 21, 2005 2:46 am ] |
Post subject: | |
man, i was totally assigned that problem 2 years ago for grade 12 programming at east elgin in aylmer ontario... i dont think i have the turing file anymore but i remember i used recursive functions to solve it. |
Author: | zylum [ Sun Oct 23, 2005 9:07 pm ] |
Post subject: | |
here's a better one i came up with: You are to find the fewest number of moves a knight must make to capture 0 < p <= 20 peices which are placed on various squares on an NxM chess board where 4 <= M, N <= 100. These peices are immobile and will not move. Input: The first line will contain N and M separated by a single space. The next line will contain the column and the row which the knight begins at, separated by a single space. The next line will be p. The next p lines will be the columns and rows of each peice separated by a single space. You can assume no set of coordinates will be repeated. Output: Print the fewest number of moves to capture all of the peices. * The first person to submit a solution that runs in under 10 seconds will receive 100 bits!!! * |
Author: | MysticVegeta [ Mon Oct 24, 2005 2:01 pm ] |
Post subject: | |
Blade wrote: man, i was totally assigned that problem 2 years ago for grade 12 programming at east elgin in aylmer ontario... i dont think i have the turing file anymore but i remember i used recursive functions to solve it.
oh my god! seriously?! Someone else figured that could be a problem sooner than i did ![]() ![]() ![]() ![]() |
Author: | [Gandalf] [ Mon Oct 24, 2005 2:47 pm ] |
Post subject: | |
No, not someone, thousands of people ![]() Quote: Problem copyright by me
*cough* |
Author: | MysticVegeta [ Mon Oct 24, 2005 5:58 pm ] |
Post subject: | |
Quote: except for the chessboard I was trying to relate 2 of my interests lol. ah i feel sorta embarrased now ![]() |