Skip to main content
2 of 5
added 226 characters in body
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 6 bytes

ṗ@Ż€I%

A dyadic Link that accepts the length, \$k\$, on the left and the number of symbols, \$N\$ on the right and yields a list of lists of non-negative integers.

Try it online!

How?

ṗ@Ż€I% - Link: k, N
 @     - with swapped arguments:
ṗ      -   [1..N] Cartesian product [1..k]
  Ż€   - prefix a zero to each
    I  - incremental differences
     % - modulo N
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282