Python Program for Number of stopping station problem Last Updated : 14 Mar, 2023 Comments Improve Suggest changes Like Article Like Report There are 12 intermediate stations between two places A and B. Find the number of ways in which a train can be made to stop at 4 of these intermediate stations so that no two stopping stations are consecutive? Examples - Input : n = 12, s = 4 Output : 126 Input : n = 16, s = 5 Output : 792 Python3 # Python code to calculate number # of ways of selecting \'p\' non # consecutive stations out of # \'n\' stations def stopping_station( p, n): num = 1 dem = 1 s = p # selecting \'s\' positions # out of \'n-s+1\' 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: # if conditions does not # satisfy of combinatorics return -1 # driver code num = stopping_station(4, 12) if num != -1: print(num) else: print("Not Possible") # This code is contributed by "Abhishek Sharma 44" Output : 126 Please refer complete article on Number of stopping station problem for more details! Comment More infoAdvertise with us Next Article Python Program for Number of stopping station problem K kartik Follow Improve Article Tags : Python Programs DSA Similar Reads Python program to count positive and negative numbers in a list In this article, we will explore various methods to count positive and negative numbers in a list. The simplest way to do this is by using a loop. This method counts the positive and negative numbers in a list by iterating through each element using for loop.Pythona = [10, -20, 30, -40, 50, -60, 0] 2 min read Python - range() for Float Numbers The range() function in Python is often used to create a sequence of numbers. However by default, it works only with integers. What if we want to use range() with float numbers? Letâs explore how we ca work with range() with float numbers. Using numpy.arange()For a cleaner solution, we can use numpy 2 min read Output of Python programs | Set 10 (Exception Handling) Pre-requisite: Exception Handling in PythonNote: All the programs run on python version 3 and above. 1) What is the output of the following program?Python data = 50 try: data = data/0 except ZeroDivisionError: print('Cannot divide by 0 ', end = '') else: print('Division successful ', end = '') try: 3 min read Python | Print number of leap years from given list of years The problem of finding leap years is quite generic and we might face the issue of finding the number of leap years in the given list of years. Letâs discuss certain ways in which this can be performed in Python. Rules to Check a Leap Years in Python To check if a number is a Leap year or not, two co 4 min read Python Program to Find Armstrong Number in an Interval We are given an interval, that is a start and an end value. We have to find all the Armstrong numbers in the given range. In this article, we will discuss how to find the Armstrong Number in an interval in Python.Armstrong NumberA number is referred to as an Armstrong number if the sum of each digit 4 min read Like