combination python

Solutions on MaxInterview for combination python by the best coders in the world

showing results for - "combination python"
Giulio
09 Oct 2019
1# 1. Print all combinations 
2from itertools import combinations
3
4comb = combinations([1, 1, 3], 2)
5print(list(combinations([1, 2, 3], 2)))
6# Output: [(1, 2), (1, 3), (2, 3)]
7
8# 2. Counting combinations
9from math import comb
10print(comb(10,3))
11#Output: 120
12