- Related Questions & Answers
- C Program for Number of stopping station problem
- Python Program for Activity Selection Problem
- Python Program for Subset Sum Problem
- Python Program for 0-1 Knapsack Problem
- Minimum Number of Platforms Required for a Railway Station using C++.
- Python Program for factorial of a number
- C Program for Activity Selection Problem
- Minimum Number of Jumps Problem
- Minimum Number of Platforms Problem
- Python Program for nth Catalan Number
- Python Program for Triangular Matchstick Number
- Python Program for Find minimum sum of factors of number
- Python Program for Product of unique prime factors of a number
- Python Program for Find sum of even factors of a number
- Python Program for Find sum of odd factors of a number

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given that there are 13 intermediate stations between two places A and B. We need to find the number of ways in which a train can be stopped at 2 intermediate stations, such that there are no consecutive stations?

Now let’s observe the solution in the implementation below −

# stop station def stopping_station( p, n): num = 1 dem = 1 s = p # selecting specified position while p != 1: dem *= p p-=1 t = n - s + 1 while t != (n-2 * s + 1): num *= t t-=1 if (n - s + 1) >= s: return int(num/dem) else: # condition return -1 # main num = stopping_station(2, 13) if num != -1: print("No of stopping stations:",num) else: print("I'm Possible")

No of stopping stations: 66

All the variables are declared in the local scope and their references are seen in the figure above.

In this article, we have learned about how we can make a Python Program for the Number of stopping station problems.

Advertisements