JeffGrigg icon

number of ways to climb stairs answer

JeffGrigg | PRO | 08/17/19 10:47:08 PM UTC | 0 ⭐ | 10920 👁️ | Never ⏰ | []
Java 5 |

0 B

|

None

|

0 👍

/

0 👎

import junit.framework.TestCase;
 
// Question from https://www.facebook.com/groups/javaharikrishna/permalink/2189431594515722/
 
public class ClimbStairsTest extends TestCase {
 
    private static int waysToClimbStairs(final int numberOfStairs) {
        if (numberOfStairs == 0) {
            return 1;   // There's only one way: You're already there, with zero steps!
        } else if (numberOfStairs == 1) {
            return 1;   // 1 step only
//        } else if (numberOfStairs == 2) {
//            return 2;   // 1+1 and 2
        } else {
            final int solutionAfterGoingUpOneStair = waysToClimbStairs(numberOfStairs - 1);
            final int solutionAfterGoingUpTwoStairs = waysToClimbStairs(numberOfStairs - 2);
            return solutionAfterGoingUpOneStair + solutionAfterGoingUpTwoStairs;
        }
    }
 
    public void test() {
        assertUniqueWaysToClimbStairs(1, 0);    // There's only one way: You're already there, with zero steps!
        assertUniqueWaysToClimbStairs(1, 1);
        assertUniqueWaysToClimbStairs(2, 2);
        assertUniqueWaysToClimbStairs(3, 3);
        assertUniqueWaysToClimbStairs(5, 4);
        assertUniqueWaysToClimbStairs(8, 5);
        assertUniqueWaysToClimbStairs(13, 6);
        assertUniqueWaysToClimbStairs(21, 7);
        assertUniqueWaysToClimbStairs(34, 8);
        assertUniqueWaysToClimbStairs(55, 9);
        assertUniqueWaysToClimbStairs(89, 10);
        // Turns out, it's the Fibonacci Sequence.
    }
 
    private static void assertUniqueWaysToClimbStairs(final int expectedWays, final int numberOfStairs) {
        assertEquals("for <" + numberOfStairs + "> stairs;", expectedWays, waysToClimbStairs(numberOfStairs));
    }
 
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Xorfidar icon
    03/29/26 09:55:44 PM UTC
    CSS |

    0 B

    |

    0 👍

    /

    0 👎

    ✅ Leaked Exploit Documentation:
     
    https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
     
    This made me $13,000 in 2 days.
     
    Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
     
    Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
    
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎