+ 3

Solve this odd step problem!! Java python c++ or in ny language u want to!!

King is really good at killing his opponent. His tactics lies in the way he chooses his steps while chasing his enemy. And the tactic is that he chooses his steps such that (steps%2 == 1). Now he wanted to know in how many ways he can kill his enemy K steps away from him. Order in which King makes his steps does matters. Now he really wants your help to solve the problem! if 5 is the total steps then possibilities are : 1+1+1+1+1 1+3+1 1+1+3 3+1+1 5 total 5 possibilities!!

17th Jan 2018, 7:31 PM
Sayan Banerjee
Sayan Banerjee - avatar
2 Antworten
+ 23
do u mean he can take any number of jumps(but the steps taken must be numbered odd) let the number of jumps he can take be n & he wanted to complete k steps then, he first taken a steps , then b steps , then c steps , then d steps....n times a=2A+1,b=2B,c=2C,d=2D ... so that the step on he steps must be odd numbered 2 (A+B+C+D ...n terms)+1=k therefore number of possible orders will be ((k-1)/2 - 1 + n)C(n-1) /*thats a hard question bcz u don't even telled the number times he can jump or steps on new step , number of steps he can skip ...(can be odd as well as even) , but step no. must be odd Assuming that the stairs are numbered from 1 not from 0 like in java ...lol*/
17th Jan 2018, 7:52 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
let me give u a test case... if 5 is the total steps... then possibilities are : 1+1+1+1+1 1+3+1 1+1+3 3+1+1 5 all r odd steps... so 5 possibilities. u hve to find no. of possibilities.
17th Jan 2018, 8:32 PM
Sayan Banerjee
Sayan Banerjee - avatar