by Barry Allen | Aug 16, 2021 | Python Programs
Introduction The task is to solve Tower of Hanoi problem using python programming. There are set of rules to follow while solving the problem: At a time only one disk is allowed to be moved. Only the uppermost disk is allowed to be moved. Disks can only be placed on... by Barry Allen | Aug 15, 2021 | Python Programs
Introduction The task to find and print the smallest M digit number divisible by N. Program def result(n, m): x = pow(10, m-1) if( x % n == 0): print(x) else: print((x + n) – ((x + n) % n)) n = 64 m = 8 result(n, m)... by Barry Allen | Aug 14, 2021 | Python Programs
Introduction The task is to print the product of unique prime factors of the given number. Program def find(ip_num): # Initializing product with 1 prod = 1 for num in range(2, ip_num+1): if (ip_num % num == 0): prime_true = 1 ... by Barry Allen | Aug 13, 2021 | Python Programs
Introduction The task is to print all the prime numbers smaller than or equal to the given number n (given n must be small). Program def SOE(ip_num): # Initialize all the element with True, the value will be False if p_num[val] is not prime p_num = [True for val... by Barry Allen | Aug 12, 2021 | Python Programs
Introduction Given a matrix of size n*n, the task is to print the elements in Z form. Program ip_array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] length = len(ip_array[0]) #Print first line n = 0 for m in range(0,... by Barry Allen | Aug 11, 2021 | Python Programs
Introduction The task is to find the number of ways we can stop the train at K stations out of N stations between S1 and S2 such that the stopping stations are non-consecutive. Program def find( s, ts): #select s non-consecutive station from ts number of stations...