Skip to content

Words ​

The strings of length sizesize over a basebase-letter alphabet {1,…,base}\{1, …, base\}.

Words(size, base)the strings of length sizesize over a basebase-letter alphabet {1,…,base}\{1, …, base\}
Typed signatures
TypePackageApplies
(integer<0..>, integer<0..>) -> indexed_collection<word>combinatoricsalways

Domain: Collections

Details
  • Count is basesizebase^{size}; the same family as Tuples, with grades reordered.

Definition

Epsil, as the implementation runs it.

count(_size, _base)

1 if _size == 0 else _base ^ _size

unrank(_size, _base, _r)

Map(Function(
              (_r - _r % _base ^ (_size - j)) / _base ^ (_size - j) % _base + 1,
              j,
            ), Range(1, _size, 1))

rank(_size, _base, _x)

Fold(Function(acc * _base + (_x[j] - 1), acc, j), 0, Range(1, _size, 1))

valid(_size, _base, _x)

Length(_x) == _size && Fold(
                             Function(ok_j && 1 <= _x[j] && _x[j] <= _base + 1 -
                                                                     1, ok_j, j),
                             True,
                             Range(1, Length(_x), 1),
                           )

Enumeration

Examples

1 more kept as data, checked against the oracles
Basic #

Count(Words(3,2))=8Count(Words(3, 2)) = 8

live ↗
InCount(Words(3,2))\mathrm{Count}(\mathrm{Words}(3, 2))Out88

The first element in enumeration order

live ↗
InWords(3,2)[1]\mathrm{Words}(3, 2)[1]OutWord⁡([1,1,1]){\operatorname{Word}}([1, 1, 1])
About
Examples3
CrosswalkSageMathSymPymathlib4

See also: Tuples, BinaryWords