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 | Print number of leap years from given list of years K kartik Follow Improve Article Tags : Python Programs DSA Similar Reads 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 | 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 | 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 How To Create a Countdown Timer Using Python? In this article, we will see how to create a countdown timer using Python. The code will take input from the user regarding the length of the countdown in seconds. After that, a countdown will begin on the screen of the format 'minutes: seconds'. We will use the time module here.Step-by-Step Approac 2 min read Like