Python provide direct methods to find permutations and combinations of a sequence. These methods are present in itertools package.
Permutation
First import itertools...

Share

Prerequisite- Binary Decoder, Multiplexers
A Decoder is a combinational circuit that converts binary information from input lines to unique output lines. Apart fro...

Share

Prerequisite – Combinational circuits using Decoder, Introduction of Sequential Circuits
Combinational circuits are defined as the time independent circuits wh...

Share

Given an array of positive integers arr[] and a sum x, find all unique combinations in arr[] where the sum is equal to x. The same repeated number may be chosen from ...

Share

Given a positive number n, we need to find all the combinations of 2*n elements such that every element from 1 to n appears exactly twice and distance between its app...

Share

Given N, we have to find the sum of products of all combination taken 1 to N at a time. In simple words, we have to find the sum of products of all combination taken ...

Share

Compute the shortest string for a combination of two given strings such that the new string consist of both the strings as its subsequences.
Examples :
Input : a = &q...

Share

Given a number k, find all the possible combinations of k-bit numbers with n-bits set where 1 <= n <= k. The solution should print all numbers with one set bit ...

Share

Given an array of size n, generate and print all possible combinations of r elements in array. For example, if input array is {1, 2, 3, 4} and r is 2, then output s...

Share

Write a function to generate all possible n pairs of balanced parentheses.
Examples:
Input : n=1
Output: {}
Input : n=2
Output:
{}{}
{{}}
Algorithm:
Keep track of...

Share