Combinations (Function) — Skript

Addon: Skript · Category: Function

Syntax

combinations(options: number, selected: number) :: number

Description

Get the number of possible sets from 1 to 'options' with each set having a size equal to 'selected' For example, a combination with 3 options and a set size of 1, returns 3: (1), (2), (3) A combination of 3 options with a set size of 2 returns 3: (1, 2), (1, 3), (2, 3) Note that the bigger the 'options' and lower the 'selected' may result in approximations or even infinity values. Combinations differ from permutations in that combinations focus on unique sets, ignoring the order of elements, whereas permutations account for the arrangement of elements within the set. Example: (1, 2) and (2, 1) represent a single combination since order doesn't matter in combinations, but they are two distinct permutations because permutations consider the order.

Examples

combinations(10, 8) = 45
combinations(5, 3) = 10
combinations(size of {some list::*}, 2)

View source