0

Today i came across this Tower of Hanoi problem from Facebook and here is the question and solution for this - Facebook sample puzzle: Towers of Hanoi But the problem i am facing is i am not able to understand the inputs given here . i know the basics of tower of Hanoi. i am not able to understand this part

Constraints: 1<= N<=8 3<= K<=5

Input Format: N K
2nd line contains N integers. Each integer in the second line is in the range 1 to K where the i-th integer denotes the peg to which disc of radius i is present in the initial configuration. 3rd line denotes the final configuration in a format similar to the initial configuration.

N and K are inputs where N is the number of disks and K is the number of pegs. But what is the initial configuration and final configuration here is an example.

Sample Input #00:

2 3

1 1

2 2

where 2 is the Number of disks and 3 is the number of pegs what the next line 1 1 and 2 2. can anyone please help me in understanding this problem and correct me if my understanding is wrong.

Community
  • 1
  • 1
shashi27
  • 189
  • 4
  • 19

1 Answers1

1

This sample input denotes: Both disks are on the first peg, and you should move them to the second peg.

Another sample input:

6 4
4 2 4 3 1 1
1 1 1 1 1 1

describes this placement:

5     1 
6 2 4 3
_ _ _ _
MBo
  • 77,366
  • 5
  • 53
  • 86