Jump to content

C programming contest problem


nafiulislam

Recommended Posts

Here is a problem given below. I am badly in need of the solution of the problem:

"Snake and ladder" is a game played in 10*10 board containing some cells number from 1 to 100.But 'Luffy(a boy)' doesn't like snake.So recently he has created a new version of the game with no snakes named 'Only ladder is real'.In this new game a player starts from the position 1 and the goal is to reach 100. In each move he can move forward up to 6 cells.But some cells contain a ladder.A ladder takes him up from one cell to another. If he reaches the bottom part of a ladder, he will immediately move to the cell which contains the upper part of the ladder. For example assume cell 5 contains a ladder which ends at cell 15. Then if palyer reaches at cell 5, he will jump to cell 15. And if there is another ladder at cell 15 which ends at cell 60. He will directly move to cell 60 from 5. Note that there is no ladder in cell 1 and cell can contain at most one bottom part and at most one top part of a ladder. Find the minimum number of moves in a given board.

 

Input specification:

The first line of the input contains number of test cases,T(T<=100).

In each case the first line contains the number of ladders,L(L<=20).Then follows “ L” lines each of which describes a ladder AB, where A(2<=A<=99) is the bottom cell of the ladder and B(B>A) is the top cell of the ladder.

 

Output spcification:

For each case print the case number and the minimum number of moves to reach from cell 1 to 100.

sample Inpu-outputt:

INPUT:

3

1

6 50

3

60 40

50 80

60 70

3

2 50

50 80

80 100

OUTPUT:

case 1:10

case 2:7

case 3:1

 

 

 

please tell me the planning to solve it in c or if u are interested to solve it, give your code... plzzzzz.

 

Link to comment
Share on other sites

Have you made a start at this?

How far have you got?
What specific problems have you encountered?

Are your problems with the algorithm, choosing appropriate data structures, C syntax, standard libraries, or ... ?

 

Or are you just expecting someone else to do the work for you (and then you get the prize)? That would be lazy and dishonest, so I hope it is not the case.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.