JaptJapt, 7 bytes7 6 bytes
ËÆDcÈÇX
c ö
Explanation
Implicit input of array U
.
Ë
Map over the array passing each element through a function where D
is the current element.Try it
ÆDcÈÇX\nö :Implicit input of array U
Generate an array of length D
and fill it with D
.
c :Flat map by
Flatten.
È :Passing each X through the following function
ÇX : Map the range [0,X) to X
\n :Reassign to U
ö :Random element
Get a random element.