Skip to content

Instantly share code, notes, and snippets.

@Parihsz
Last active February 12, 2024 20:15
Show Gist options
  • Select an option

  • Save Parihsz/82c658050b66361982240b7d12c93fe0 to your computer and use it in GitHub Desktop.

Select an option

Save Parihsz/82c658050b66361982240b7d12c93fe0 to your computer and use it in GitHub Desktop.
comp programming common libraries

to be done

Itertools

Itertools has 4 functions

Permutations

n items from a collection of m

Combinations_With_Replacement

complicated, not often used in comp programming

Combinations

permutations without internal ordering

Product

a, a number of collections, the ways to choose one from each
    one vegetable, one meat, one starch ....
b, one collection, repeated n times, each choosing from the collection
    digits building numbers or letters building words/sentences

Usage

"""
The number of ways to have 3 sorted numbers
between 1 inclusive and X (number of fourth player) exclusive
"""
import itertools
X = int(input())
results = itertools.combinations(range(X - 1), 3)
print(len(results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment