Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Programming Problem - Knight Move!
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MysticVegeta




PostPosted: 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

code:
.X.X
X...
..0.
X...


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
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Thu Oct 20, 2005 4:58 pm   Post subject: (No 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.
Blade




PostPosted: Fri Oct 21, 2005 2:46 am   Post subject: (No 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.
zylum




PostPosted: Sun Oct 23, 2005 9:07 pm   Post subject: (No 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!!! *
MysticVegeta




PostPosted: Mon Oct 24, 2005 2:01 pm   Post subject: (No 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 Mad Mad Mad Embarassed
[Gandalf]




PostPosted: Mon Oct 24, 2005 2:47 pm   Post subject: (No subject)

No, not someone, thousands of people Smile. I recently saw somebody doing a problem like this for a logic course, except for the whole chess board.

Quote:
Problem copyright by me

*cough*
MysticVegeta




PostPosted: Mon Oct 24, 2005 5:58 pm   Post subject: (No subject)

Quote:
except for the chessboard
I was trying to relate 2 of my interests lol. ah i feel sorta embarrased now Embarassed
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: