Deal the cards to the players
05AB1E, 3 1 byte
Saved 2 bytes thanks to Adnan
ι
Try it online! or as a Test Suite
Explanation
ι # uninterleave
Does exactly what the challenge asks for
R, 46 25 bytes
function(A,n)split(A,1:n)
Try it online!
split
s A
into groups defined by 1:n
, recycling 1:n
until it matches length with A
.
Perl 6, 33 24 bytes
->\b{*.classify:{$++%b}}
Try it online!
Anonymous curried code block that takes a number and returns a Whatever lambda that takes a list and returns a list of lists. This takes the second option when given a number larger than the length of lists, e.g. f(4)([1,2,3])
returns [[1],[2],[3]]
Explanation:
->\b{ } # Anonymous code block that takes a number
* # And returns a Whatever lambda
.classify # That groups by
:{$++%b} # The index modulo the number