Skip to content

pactole-js


Class: BoundCombination

Defined in: combinations/combination.ts:471

A class representing a bound combination of values.

BoundCombination extends Combination with numeric bounds and a fixed component count used by lottery sub-components.

Param

The values of the combination. If an integer is provided, it is treated as a rank.

Param

The lexicographic rank of the combination.

Param

The start value of the combination range.

Param

The end value of the combination range.

Param

The maximum count of numbers in the combination.

Param

The total number of possible combinations.

Examples

const bound = new BoundCombination(10, { start: 1, end: 50, count: 5 });
bound.values; // e.g. [2, 3, 4, 5, 7]
const fixed = new BoundCombination([1, 2, 3], { start: 1, end: 50, count: 5 });
fixed.count; // 5
fixed.combinations; // 2118760

Extends

Constructors

Constructor

new BoundCombination(values?, __namedParameters?): BoundCombination

Defined in: combinations/combination.ts:478

Parameters

values?

CombinationInputOrRank = null

__namedParameters?

BoundCombinationOptions = {}

Returns

BoundCombination

Overrides

Combination.constructor

Properties

_combinations

protected readonly _combinations: number

Defined in: combinations/combination.ts:476


_count

protected readonly _count: number

Defined in: combinations/combination.ts:474


_end

protected readonly _end: number

Defined in: combinations/combination.ts:472


_rank

protected _rank: number | null

Defined in: combinations/combination.ts:85

Inherited from

Combination._rank


_start

protected readonly _start: number

Defined in: combinations/combination.ts:87

Inherited from

Combination._start


_values

protected readonly _values: Set\<number>

Defined in: combinations/combination.ts:83

Inherited from

Combination._values

Accessors

combinations

Get Signature

get combinations(): number

Defined in: combinations/combination.ts:560

Return the total number of possible combinations.

Example
new BoundCombination([1, 2, 3], null, 1, 50, 5).combinations; // 2118760
Returns

number

Total combinatorial space.


count

Get Signature

get count(): number

Defined in: combinations/combination.ts:548

Return the configured count of numbers in the combination.

Example
new BoundCombination([1, 2, 3], null, 1, 50, 5).count; // 5
Returns

number

Configured count.


end

Get Signature

get end(): number

Defined in: combinations/combination.ts:536

Return the end value of the combination range.

Example
new BoundCombination([1, 2, 3], null, 1, 50, 5).end; // 50
Returns

number

End bound.


length

Get Signature

get length(): number

Defined in: combinations/combination.ts:180

Get number of values.

Example
new Combination([3, 1, 2]).length; // 3
Returns

number

Number of unique values in the combination.

Inherited from

Combination.length


rank

Get Signature

get rank(): number

Defined in: combinations/combination.ts:155

Get lexicographic rank.

If rank is not explicitly provided, it is computed lazily from values.

Example
new Combination([3, 1, 2]).rank; // 0
Returns

number

Lexicographic rank.

Inherited from

Combination.rank


start

Get Signature

get start(): number

Defined in: combinations/combination.ts:192

Get the starting offset of the combination.

Example
new Combination([3, 1, 2], null, 0).start; // 0
Returns

number

Start offset.

Inherited from

Combination.start


storedRank

Get Signature

get storedRank(): number | null

Defined in: combinations/combination.ts:168

Get the stored rank without triggering lazy rank computation.

Returns

number | null

Stored rank or null when it has not been set/computed yet.

Inherited from

Combination.storedRank


values

Get Signature

get values(): CombinationValues

Defined in: combinations/combination.ts:137

Get sorted combination values.

Example
new Combination([3, 1, 2]).values; // [1, 2, 3]
Returns

CombinationValues

Sorted values.

Inherited from

Combination.values

Methods

[iterator]()

[iterator](): Iterator\<number>

Defined in: combinations/combination.ts:444

Returns

Iterator\<number>

Inherited from

Combination.[iterator]


compares()

compares(combination): number

Defined in: combinations/combination.ts:358

Compare this combination to another combination or rank.

Parameters

combination

CombinationInput

Candidate combination/rank.

Returns

number

-1, 0, or 1.

Example

new Combination([1, 2, 3]).compares([1, 2, 4]); // -1

Inherited from

Combination.compares


copy()

copy(values?): BoundCombination

Defined in: combinations/combination.ts:594

Return a copy of the BoundCombination with optional modifications.

Parameters

values?

BoundCombinationCopyOptions = {}

Replacement values, rank, or input-with-rank payload.

Returns

BoundCombination

A new BoundCombination.

Example

const base = new BoundCombination([1, 2, 3], { start: 1, end: 50, count: 5 });
base.copy({ values: 15 }).values; // rank-derived bounded values

Overrides

Combination.copy


equals()

equals(combination): boolean

Defined in: combinations/combination.ts:257

Check whether this combination equals another combination or rank.

Parameters

combination

CombinationInput

Candidate combination/rank.

Returns

boolean

true when values/rank are equal.

Example

const base = new Combination([1, 2, 3]);
base.equals([1, 2, 3]); // true
base.equals(0); // true

Inherited from

Combination.equals


generate()

generate(n?): BoundCombination[]

Defined in: combinations/combination.ts:575

Generate random combinations within current bounds.

Parameters

n?

BoundCombinationGenerateOptions = {}

Number of combinations to generate.

Returns

BoundCombination[]

Generated combinations.

Example

const generated = new BoundCombination(null, { start: 1, end: 50, count: 5 }).generate({ n: 2 });
generated.length; // 2

get()

get(index): number

Defined in: combinations/combination.ts:408

Get a value by index.

Parameters

index

number

Zero-based value index.

Returns

number

Value at index.

Throws

Thrown when index is out of bounds.

Inherited from

Combination.get


getValues()

getValues(start?): CombinationValues

Defined in: combinations/combination.ts:237

Get values with an optional start offset transformation.

Parameters

start?

number

Optional target start offset.

Returns

CombinationValues

Values adjusted to the requested start offset.

Example

new Combination([1, 2, 3]).getValues(0); // [0, 1, 2]

Inherited from

Combination.getValues


hashCode()

hashCode(): number

Defined in: combinations/combination.ts:424

Get an integer hash representation.

Returns

number

Rank-based hash.

Example

new Combination([1, 2, 3]).hashCode(); // 0

Inherited from

Combination.hashCode


includes()

includes(combination): boolean

Defined in: combinations/combination.ts:292

Check whether this combination includes another combination or a value.

Parameters

combination

Candidate value(s).

number | CombinationInputValues | null | undefined

Returns

boolean

true when all candidate values are included.

Example

const base = new Combination([2, 4, 6]);
base.includes(4); // true
base.includes([2, 5]); // false

Inherited from

Combination.includes


intersection()

intersection(combination): Combination

Defined in: combinations/combination.ts:340

Get the intersection with another combination.

Parameters

combination

Candidate value(s).

CombinationInputValues | null | undefined

Returns

Combination

A new Combination containing shared values.

Example

new Combination([1, 2, 3]).intersection([3, 4, 5]).values; // [3]

Inherited from

Combination.intersection


intersects()

intersects(combination): boolean

Defined in: combinations/combination.ts:318

Check whether this combination intersects another combination.

Parameters

combination

Candidate value(s).

CombinationInputValues | null | undefined

Returns

boolean

true when at least one value overlaps.

Example

new Combination([1, 2, 3]).intersects([3, 4]); // true

Inherited from

Combination.intersects


similarity()

similarity(combination): number

Defined in: combinations/combination.ts:388

Calculate similarity ratio with another combination.

Parameters

combination

Candidate values.

CombinationInputValues | null | undefined

Returns

number

Similarity ratio in [0, 1].

Example

new Combination([1, 2, 3]).similarity([2, 3, 4]); // 0.666...

Inherited from

Combination.similarity


toRepr()

toRepr(): string

Defined in: combinations/combination.ts:656

Render string representation.

Returns

string

Representation string.

Example

new BoundCombination([1, 2, 3], null, 1, 50, 5).toRepr();

Overrides

Combination.toRepr


toString()

toString(): string

Defined in: combinations/combination.ts:637

Render values with fixed-width formatting.

Returns

string

Human-readable combination string.

Example

new BoundCombination([1, 2, 3], null, 1, 50, 5).toString();

Overrides

Combination.toString