Deal the cards to the playersCreate chunks from an arraySimple One Game BlackjackName the poker hand - 7...

Is there a way to find out the age of climbing ropes?

Why did the Cray-1 have 8 parity bits per word?

Did Amazon pay $0 in taxes last year?

Do AL rules let me pick different starting equipment?

Can I solder 12/2 Romex to extend wire 5 ft?

I can't die. Who am I?

Meaning of word ягоза

Plagiarism of code by other PhD student

Inconsistent behaviour between dict.values() and dict.keys() equality in Python 3.x and Python 2.7

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Make me a metasequence

Why would the IRS ask for birth certificates or even audit a small tax return?

How to kill a localhost:8080

PTIJ: What’s wrong with eating meat and couscous?

Why won't the strings command stop?

Why is my Contribution Detail Report (native CiviCRM Core report) not accurate?

If nine coins are tossed, what is the probability that the number of heads is even?

Can a space-faring robot still function over a billion years?

Practical reasons to have both a large police force and bounty hunting network?

When do _WA_Sys_ statistics Get Updated?

GPL code private and stolen

Specific Chinese carabiner QA?

Can an earth elemental drown/bury its opponent underground using earth glide?

Is divide-by-zero a security vulnerability?



Deal the cards to the players


Create chunks from an arraySimple One Game BlackjackName the poker hand - 7 cards editionCompare two poker handsDetermine the winner of a game of WarHelp me cheat at CheatScore a hand of HeartsGolf an unbeatable chopsticks bot1326 starting hold'em combosBadugi, Who Wins?Deal an ASCII Deck













3












$begingroup$


Tonight is card game night! You are the dealer and your task is to write a program to deal the cards to the players.



Given an array of card and a number of player, you need to split the array into hand for each player.



example for 4 players with a deck of 10 cards



Rules



Your program will receive an non-empty array A , as well as a non-zero positive integer n. The array should then be split into n hands, if the length of the string isn't divisible by n any leftover at the end should be distributed as evenly as possible.




  • If n is equals to 1, you will need to return an array of array A

  • If n is greater than the length of A, you will need to return every hands and an empty hand. if n = 4 and array A = [1,2,3], you should return [[1],[2],[3]] or [[1],[2],[3],[]]. You are free to handle the empty hand with empty, undefined or null.


  • The array can contain any type rather than a number.


  • You should not change order (or direction) of any item from left to right. For example if n = 2 and A= [1,2,3]. Any result rather than [[1,3],[2]] will be invalid.



Test Cases



n   A               Output

1 [1,2,3,4,5,6] [[1,2,3,4,5,6]]
2 [1,2,3,4,5,6] [[1,3,5],[2,4,6]]
3 [1,2,3,4,5,6] [[1,4],[2,5],[3,6]]
4 [1,2,3,4,5,6] [[1,5],[2,6],[3],[4]]
7 [1,2,3,4,5,6] [[1],[2],[3],[4],[5],[6]] // or [[1],[2],[3],[4],[5],[6],[]]


Demo





def deal(cards, n):
i = 0
players = [[] for _ in range(n)]
for card in cards:
players[i % n].append(card)
i += 1
return players

hands = deal([1,2,3,4,5,6], 2)

for hand in hands:
print(hand)


Try it online!



This is code-golf, so you the shortest bytes of each language will be the winner.



Inspired from Create chunks from array by chau giang










share|improve this question











$endgroup$








  • 1




    $begingroup$
    All the test cases seem to split A into n chunks rather than into chunks of size n.
    $endgroup$
    – Adám
    37 mins ago






  • 1




    $begingroup$
    should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
    $endgroup$
    – Adám
    27 mins ago






  • 1




    $begingroup$
    @aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
    $endgroup$
    – Adám
    24 mins ago






  • 1




    $begingroup$
    you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
    $endgroup$
    – Adám
    22 mins ago






  • 3




    $begingroup$
    In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
    $endgroup$
    – Jo King
    20 mins ago
















3












$begingroup$


Tonight is card game night! You are the dealer and your task is to write a program to deal the cards to the players.



Given an array of card and a number of player, you need to split the array into hand for each player.



example for 4 players with a deck of 10 cards



Rules



Your program will receive an non-empty array A , as well as a non-zero positive integer n. The array should then be split into n hands, if the length of the string isn't divisible by n any leftover at the end should be distributed as evenly as possible.




  • If n is equals to 1, you will need to return an array of array A

  • If n is greater than the length of A, you will need to return every hands and an empty hand. if n = 4 and array A = [1,2,3], you should return [[1],[2],[3]] or [[1],[2],[3],[]]. You are free to handle the empty hand with empty, undefined or null.


  • The array can contain any type rather than a number.


  • You should not change order (or direction) of any item from left to right. For example if n = 2 and A= [1,2,3]. Any result rather than [[1,3],[2]] will be invalid.



Test Cases



n   A               Output

1 [1,2,3,4,5,6] [[1,2,3,4,5,6]]
2 [1,2,3,4,5,6] [[1,3,5],[2,4,6]]
3 [1,2,3,4,5,6] [[1,4],[2,5],[3,6]]
4 [1,2,3,4,5,6] [[1,5],[2,6],[3],[4]]
7 [1,2,3,4,5,6] [[1],[2],[3],[4],[5],[6]] // or [[1],[2],[3],[4],[5],[6],[]]


Demo





def deal(cards, n):
i = 0
players = [[] for _ in range(n)]
for card in cards:
players[i % n].append(card)
i += 1
return players

hands = deal([1,2,3,4,5,6], 2)

for hand in hands:
print(hand)


Try it online!



This is code-golf, so you the shortest bytes of each language will be the winner.



Inspired from Create chunks from array by chau giang










share|improve this question











$endgroup$








  • 1




    $begingroup$
    All the test cases seem to split A into n chunks rather than into chunks of size n.
    $endgroup$
    – Adám
    37 mins ago






  • 1




    $begingroup$
    should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
    $endgroup$
    – Adám
    27 mins ago






  • 1




    $begingroup$
    @aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
    $endgroup$
    – Adám
    24 mins ago






  • 1




    $begingroup$
    you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
    $endgroup$
    – Adám
    22 mins ago






  • 3




    $begingroup$
    In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
    $endgroup$
    – Jo King
    20 mins ago














3












3








3





$begingroup$


Tonight is card game night! You are the dealer and your task is to write a program to deal the cards to the players.



Given an array of card and a number of player, you need to split the array into hand for each player.



example for 4 players with a deck of 10 cards



Rules



Your program will receive an non-empty array A , as well as a non-zero positive integer n. The array should then be split into n hands, if the length of the string isn't divisible by n any leftover at the end should be distributed as evenly as possible.




  • If n is equals to 1, you will need to return an array of array A

  • If n is greater than the length of A, you will need to return every hands and an empty hand. if n = 4 and array A = [1,2,3], you should return [[1],[2],[3]] or [[1],[2],[3],[]]. You are free to handle the empty hand with empty, undefined or null.


  • The array can contain any type rather than a number.


  • You should not change order (or direction) of any item from left to right. For example if n = 2 and A= [1,2,3]. Any result rather than [[1,3],[2]] will be invalid.



Test Cases



n   A               Output

1 [1,2,3,4,5,6] [[1,2,3,4,5,6]]
2 [1,2,3,4,5,6] [[1,3,5],[2,4,6]]
3 [1,2,3,4,5,6] [[1,4],[2,5],[3,6]]
4 [1,2,3,4,5,6] [[1,5],[2,6],[3],[4]]
7 [1,2,3,4,5,6] [[1],[2],[3],[4],[5],[6]] // or [[1],[2],[3],[4],[5],[6],[]]


Demo





def deal(cards, n):
i = 0
players = [[] for _ in range(n)]
for card in cards:
players[i % n].append(card)
i += 1
return players

hands = deal([1,2,3,4,5,6], 2)

for hand in hands:
print(hand)


Try it online!



This is code-golf, so you the shortest bytes of each language will be the winner.



Inspired from Create chunks from array by chau giang










share|improve this question











$endgroup$




Tonight is card game night! You are the dealer and your task is to write a program to deal the cards to the players.



Given an array of card and a number of player, you need to split the array into hand for each player.



example for 4 players with a deck of 10 cards



Rules



Your program will receive an non-empty array A , as well as a non-zero positive integer n. The array should then be split into n hands, if the length of the string isn't divisible by n any leftover at the end should be distributed as evenly as possible.




  • If n is equals to 1, you will need to return an array of array A

  • If n is greater than the length of A, you will need to return every hands and an empty hand. if n = 4 and array A = [1,2,3], you should return [[1],[2],[3]] or [[1],[2],[3],[]]. You are free to handle the empty hand with empty, undefined or null.


  • The array can contain any type rather than a number.


  • You should not change order (or direction) of any item from left to right. For example if n = 2 and A= [1,2,3]. Any result rather than [[1,3],[2]] will be invalid.



Test Cases



n   A               Output

1 [1,2,3,4,5,6] [[1,2,3,4,5,6]]
2 [1,2,3,4,5,6] [[1,3,5],[2,4,6]]
3 [1,2,3,4,5,6] [[1,4],[2,5],[3,6]]
4 [1,2,3,4,5,6] [[1,5],[2,6],[3],[4]]
7 [1,2,3,4,5,6] [[1],[2],[3],[4],[5],[6]] // or [[1],[2],[3],[4],[5],[6],[]]


Demo





def deal(cards, n):
i = 0
players = [[] for _ in range(n)]
for card in cards:
players[i % n].append(card)
i += 1
return players

hands = deal([1,2,3,4,5,6], 2)

for hand in hands:
print(hand)


Try it online!



This is code-golf, so you the shortest bytes of each language will be the winner.



Inspired from Create chunks from array by chau giang







code-golf array-manipulation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 mins ago







aloisdg

















asked 1 hour ago









aloisdgaloisdg

1,4891122




1,4891122








  • 1




    $begingroup$
    All the test cases seem to split A into n chunks rather than into chunks of size n.
    $endgroup$
    – Adám
    37 mins ago






  • 1




    $begingroup$
    should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
    $endgroup$
    – Adám
    27 mins ago






  • 1




    $begingroup$
    @aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
    $endgroup$
    – Adám
    24 mins ago






  • 1




    $begingroup$
    you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
    $endgroup$
    – Adám
    22 mins ago






  • 3




    $begingroup$
    In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
    $endgroup$
    – Jo King
    20 mins ago














  • 1




    $begingroup$
    All the test cases seem to split A into n chunks rather than into chunks of size n.
    $endgroup$
    – Adám
    37 mins ago






  • 1




    $begingroup$
    should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
    $endgroup$
    – Adám
    27 mins ago






  • 1




    $begingroup$
    @aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
    $endgroup$
    – Adám
    24 mins ago






  • 1




    $begingroup$
    you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
    $endgroup$
    – Adám
    22 mins ago






  • 3




    $begingroup$
    In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
    $endgroup$
    – Jo King
    20 mins ago








1




1




$begingroup$
All the test cases seem to split A into n chunks rather than into chunks of size n.
$endgroup$
– Adám
37 mins ago




$begingroup$
All the test cases seem to split A into n chunks rather than into chunks of size n.
$endgroup$
– Adám
37 mins ago




1




1




$begingroup$
should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
$endgroup$
– Adám
27 mins ago




$begingroup$
should be give to a player as much as possible means should be distributed as evenly as possible, right? If so, please edit to actually say so.
$endgroup$
– Adám
27 mins ago




1




1




$begingroup$
@aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
$endgroup$
– Adám
24 mins ago




$begingroup$
@aloisdg Great, but now your first bulleted rule is unnecessary and wrong.
$endgroup$
– Adám
24 mins ago




1




1




$begingroup$
you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
$endgroup$
– Adám
22 mins ago




$begingroup$
you will need to return every hands and an empty hand contradicts the last test case's first result possibility.
$endgroup$
– Adám
22 mins ago




3




3




$begingroup$
In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
$endgroup$
– Jo King
20 mins ago




$begingroup$
In the future I'd recommend using the Sandbox to iron out problems and gauge community feedback before posting your question to main
$endgroup$
– Jo King
20 mins ago










5 Answers
5






active

oldest

votes


















1












$begingroup$

Japt, 2 bytes



Takes the array as the first input.



óV


Try it






share|improve this answer









$endgroup$





















    1












    $begingroup$


    R, 46 25 bytes





    function(A,n)split(A,1:n)


    Try it online!



    splits A into groups defined by 1:n, recycling 1:n until it matches length with A.






    share|improve this answer











    $endgroup$





















      1












      $begingroup$


      Python 2, 37 bytes





      Code:



      lambda x,n:[x[i::n]for i in range(n)]


      Try it online!






      share|improve this answer









      $endgroup$





















        1












        $begingroup$


        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





        share|improve this answer











        $endgroup$





















          0












          $begingroup$


          C# (Visual C# Interactive Compiler), 43 bytes





          a=>b=>{int i=0;return a.GroupBy(_=>i++%b);}


          Try it online!






          share|improve this answer









          $endgroup$













          • $begingroup$
            @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
            $endgroup$
            – aloisdg
            43 mins ago












          • $begingroup$
            It's generally discouraged to post solutions to your own challenges immediately.
            $endgroup$
            – Shaggy
            40 mins ago






          • 1




            $begingroup$
            @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
            $endgroup$
            – aloisdg
            38 mins ago










          • $begingroup$
            @Joe king you are right! I made a typo :/
            $endgroup$
            – aloisdg
            37 mins ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "200"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181029%2fdeal-the-cards-to-the-players%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$

          Japt, 2 bytes



          Takes the array as the first input.



          óV


          Try it






          share|improve this answer









          $endgroup$


















            1












            $begingroup$

            Japt, 2 bytes



            Takes the array as the first input.



            óV


            Try it






            share|improve this answer









            $endgroup$
















              1












              1








              1





              $begingroup$

              Japt, 2 bytes



              Takes the array as the first input.



              óV


              Try it






              share|improve this answer









              $endgroup$



              Japt, 2 bytes



              Takes the array as the first input.



              óV


              Try it







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 41 mins ago









              ShaggyShaggy

              19.4k21667




              19.4k21667























                  1












                  $begingroup$


                  R, 46 25 bytes





                  function(A,n)split(A,1:n)


                  Try it online!



                  splits A into groups defined by 1:n, recycling 1:n until it matches length with A.






                  share|improve this answer











                  $endgroup$


















                    1












                    $begingroup$


                    R, 46 25 bytes





                    function(A,n)split(A,1:n)


                    Try it online!



                    splits A into groups defined by 1:n, recycling 1:n until it matches length with A.






                    share|improve this answer











                    $endgroup$
















                      1












                      1








                      1





                      $begingroup$


                      R, 46 25 bytes





                      function(A,n)split(A,1:n)


                      Try it online!



                      splits A into groups defined by 1:n, recycling 1:n until it matches length with A.






                      share|improve this answer











                      $endgroup$




                      R, 46 25 bytes





                      function(A,n)split(A,1:n)


                      Try it online!



                      splits A into groups defined by 1:n, recycling 1:n until it matches length with A.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 31 mins ago

























                      answered 49 mins ago









                      GiuseppeGiuseppe

                      16.6k31052




                      16.6k31052























                          1












                          $begingroup$


                          Python 2, 37 bytes





                          Code:



                          lambda x,n:[x[i::n]for i in range(n)]


                          Try it online!






                          share|improve this answer









                          $endgroup$


















                            1












                            $begingroup$


                            Python 2, 37 bytes





                            Code:



                            lambda x,n:[x[i::n]for i in range(n)]


                            Try it online!






                            share|improve this answer









                            $endgroup$
















                              1












                              1








                              1





                              $begingroup$


                              Python 2, 37 bytes





                              Code:



                              lambda x,n:[x[i::n]for i in range(n)]


                              Try it online!






                              share|improve this answer









                              $endgroup$




                              Python 2, 37 bytes





                              Code:



                              lambda x,n:[x[i::n]for i in range(n)]


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 29 mins ago









                              AdnanAdnan

                              35.7k562225




                              35.7k562225























                                  1












                                  $begingroup$


                                  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





                                  share|improve this answer











                                  $endgroup$


















                                    1












                                    $begingroup$


                                    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





                                    share|improve this answer











                                    $endgroup$
















                                      1












                                      1








                                      1





                                      $begingroup$


                                      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





                                      share|improve this answer











                                      $endgroup$




                                      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






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 15 mins ago

























                                      answered 49 mins ago









                                      Jo KingJo King

                                      24.3k357125




                                      24.3k357125























                                          0












                                          $begingroup$


                                          C# (Visual C# Interactive Compiler), 43 bytes





                                          a=>b=>{int i=0;return a.GroupBy(_=>i++%b);}


                                          Try it online!






                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                            $endgroup$
                                            – aloisdg
                                            43 mins ago












                                          • $begingroup$
                                            It's generally discouraged to post solutions to your own challenges immediately.
                                            $endgroup$
                                            – Shaggy
                                            40 mins ago






                                          • 1




                                            $begingroup$
                                            @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                            $endgroup$
                                            – aloisdg
                                            38 mins ago










                                          • $begingroup$
                                            @Joe king you are right! I made a typo :/
                                            $endgroup$
                                            – aloisdg
                                            37 mins ago
















                                          0












                                          $begingroup$


                                          C# (Visual C# Interactive Compiler), 43 bytes





                                          a=>b=>{int i=0;return a.GroupBy(_=>i++%b);}


                                          Try it online!






                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                            $endgroup$
                                            – aloisdg
                                            43 mins ago












                                          • $begingroup$
                                            It's generally discouraged to post solutions to your own challenges immediately.
                                            $endgroup$
                                            – Shaggy
                                            40 mins ago






                                          • 1




                                            $begingroup$
                                            @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                            $endgroup$
                                            – aloisdg
                                            38 mins ago










                                          • $begingroup$
                                            @Joe king you are right! I made a typo :/
                                            $endgroup$
                                            – aloisdg
                                            37 mins ago














                                          0












                                          0








                                          0





                                          $begingroup$


                                          C# (Visual C# Interactive Compiler), 43 bytes





                                          a=>b=>{int i=0;return a.GroupBy(_=>i++%b);}


                                          Try it online!






                                          share|improve this answer









                                          $endgroup$




                                          C# (Visual C# Interactive Compiler), 43 bytes





                                          a=>b=>{int i=0;return a.GroupBy(_=>i++%b);}


                                          Try it online!







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 50 mins ago









                                          aloisdgaloisdg

                                          1,4891122




                                          1,4891122












                                          • $begingroup$
                                            @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                            $endgroup$
                                            – aloisdg
                                            43 mins ago












                                          • $begingroup$
                                            It's generally discouraged to post solutions to your own challenges immediately.
                                            $endgroup$
                                            – Shaggy
                                            40 mins ago






                                          • 1




                                            $begingroup$
                                            @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                            $endgroup$
                                            – aloisdg
                                            38 mins ago










                                          • $begingroup$
                                            @Joe king you are right! I made a typo :/
                                            $endgroup$
                                            – aloisdg
                                            37 mins ago


















                                          • $begingroup$
                                            @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                            $endgroup$
                                            – aloisdg
                                            43 mins ago












                                          • $begingroup$
                                            It's generally discouraged to post solutions to your own challenges immediately.
                                            $endgroup$
                                            – Shaggy
                                            40 mins ago






                                          • 1




                                            $begingroup$
                                            @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                            $endgroup$
                                            – aloisdg
                                            38 mins ago










                                          • $begingroup$
                                            @Joe king you are right! I made a typo :/
                                            $endgroup$
                                            – aloisdg
                                            37 mins ago
















                                          $begingroup$
                                          @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                          $endgroup$
                                          – aloisdg
                                          43 mins ago






                                          $begingroup$
                                          @JoKing [1,2,3], 4 should output [[1],[2],[3]]. You are dealing 3 cards to 4 players. I will update the main question.
                                          $endgroup$
                                          – aloisdg
                                          43 mins ago














                                          $begingroup$
                                          It's generally discouraged to post solutions to your own challenges immediately.
                                          $endgroup$
                                          – Shaggy
                                          40 mins ago




                                          $begingroup$
                                          It's generally discouraged to post solutions to your own challenges immediately.
                                          $endgroup$
                                          – Shaggy
                                          40 mins ago




                                          1




                                          1




                                          $begingroup$
                                          @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                          $endgroup$
                                          – aloisdg
                                          38 mins ago




                                          $begingroup$
                                          @Shaggy ok I will take it into account for the next time. It is fine on so and rpg but I guess the competitive aspect of codegolf made it a bit unfair to self post directly. Make sense.
                                          $endgroup$
                                          – aloisdg
                                          38 mins ago












                                          $begingroup$
                                          @Joe king you are right! I made a typo :/
                                          $endgroup$
                                          – aloisdg
                                          37 mins ago




                                          $begingroup$
                                          @Joe king you are right! I made a typo :/
                                          $endgroup$
                                          – aloisdg
                                          37 mins ago


















                                          draft saved

                                          draft discarded




















































                                          If this is an answer to a challenge…




                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                          More generally…




                                          • …Please make sure to answer the question and provide sufficient detail.


                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181029%2fdeal-the-cards-to-the-players%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          IEEEtran - How to include ORCID in TeX/PDF with PdfLatexIs there a standard way to include ORCID in TeX /...

                                          Cicindela nigrior Przypisy | Menu nawigacyjneCicindela varians unicolorManual for the Identification of the...

                                          Glossaries-extra: Adding glossaries package to “Clas­sicTh­e­sis” template by Dr. André Miede v. 4.6 ...