[algogeeks] Re: puzzle from code4bill

2006-01-25 Thread Abhi
int steps_combi(int steps) { if(steps==1) return 1; if(steps==2) return 2; // can take single step or double step return (steps_combi(steps-1) + steps_combi(steps-2)); }

[algogeeks] Re: puzzle from code4bill

2006-01-23 Thread Vishal
You have to consider permutations as well and not just combinations.This will increase the total number of ways.~VishalOn 1/23/06, Ankur Khetrapal [EMAIL PROTECTED] wrote: thisis done using integral solution method.. letx - no. of single steps lety - no of double steps x + 2y = 22 x = 22 - 2y

[algogeeks] Re: puzzle from code4bill

2006-01-23 Thread Vikram Venkatesan
Hi, It can be derived as follows... Let f(n) denote the no. of ways in which 'n' steps can be climbed... So, for climbing 'n' steps, the possible combinations are, 1. Climb one step initially.. so, n-1 steps left.. they can be climbed in f(n-1) ways, OR 2. Climb 2 steps initally... so, n-2