Randomly distribute numbers to lists

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have 4 empty lists. I would like to randomly distribute numbers from 1 to 10 to these 4 empty lists. How can I add integers to lists randomly?



For example:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];


1->m , 2->n , 3->p , 4->m , 5->r , 6->r, 7->n , 8->m, 9->p , 10->n (Randomly distributed)



Here is the code I tried:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];
s = RandomChoice[m, n, p, r, 4];
Do[listm = AppendTo[s, listz[i]];, i, 1, 10]
listm


Wanted Solution:(Randomly distributed)



m = 1, 5, 8
n = 4, 6, 9
p = 7, 10
r = 2, 3









share|improve this question







New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Why not just generate four random lists in the first place?
    – gothicVI
    2 hours ago














up vote
2
down vote

favorite












I have 4 empty lists. I would like to randomly distribute numbers from 1 to 10 to these 4 empty lists. How can I add integers to lists randomly?



For example:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];


1->m , 2->n , 3->p , 4->m , 5->r , 6->r, 7->n , 8->m, 9->p , 10->n (Randomly distributed)



Here is the code I tried:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];
s = RandomChoice[m, n, p, r, 4];
Do[listm = AppendTo[s, listz[i]];, i, 1, 10]
listm


Wanted Solution:(Randomly distributed)



m = 1, 5, 8
n = 4, 6, 9
p = 7, 10
r = 2, 3









share|improve this question







New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Why not just generate four random lists in the first place?
    – gothicVI
    2 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have 4 empty lists. I would like to randomly distribute numbers from 1 to 10 to these 4 empty lists. How can I add integers to lists randomly?



For example:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];


1->m , 2->n , 3->p , 4->m , 5->r , 6->r, 7->n , 8->m, 9->p , 10->n (Randomly distributed)



Here is the code I tried:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];
s = RandomChoice[m, n, p, r, 4];
Do[listm = AppendTo[s, listz[i]];, i, 1, 10]
listm


Wanted Solution:(Randomly distributed)



m = 1, 5, 8
n = 4, 6, 9
p = 7, 10
r = 2, 3









share|improve this question







New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have 4 empty lists. I would like to randomly distribute numbers from 1 to 10 to these 4 empty lists. How can I add integers to lists randomly?



For example:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];


1->m , 2->n , 3->p , 4->m , 5->r , 6->r, 7->n , 8->m, 9->p , 10->n (Randomly distributed)



Here is the code I tried:



m = ;
n = ;
p = ;
r = ;
listz = Range[10];
s = RandomChoice[m, n, p, r, 4];
Do[listm = AppendTo[s, listz[i]];, i, 1, 10]
listm


Wanted Solution:(Randomly distributed)



m = 1, 5, 8
n = 4, 6, 9
p = 7, 10
r = 2, 3






list-manipulation random education






share|improve this question







New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









ithilquessirr

282




282




New contributor




ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ithilquessirr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Why not just generate four random lists in the first place?
    – gothicVI
    2 hours ago
















  • Why not just generate four random lists in the first place?
    – gothicVI
    2 hours ago















Why not just generate four random lists in the first place?
– gothicVI
2 hours ago




Why not just generate four random lists in the first place?
– gothicVI
2 hours ago










4 Answers
4






active

oldest

votes

















up vote
2
down vote













on Mathematica 11.3



(R=RandomSample)[Range@10,10]~TakeList~R@RandomChoice[Select[IntegerPartitions@10,Length@#==4&]] 





Also I tried to fix your code



a = ;
b = ;
c = ;
d = ;
Listz = a, b, c, d;
Do[t=RandomChoice@Range@4;Listz[[t]]=AppendTo[Listz[[t]],i],i,1,10]
Listz





share|improve this answer






















  • Have you tried that with a list of 100 elements?
    – Henrik Schumacher
    1 hour ago










  • how about 10^100?
    – J42161217
    1 hour ago










  • @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
    – Okkes Dulgerci
    1 hour ago











  • @OkkesDulgerci fixed!
    – J42161217
    1 hour ago


















up vote
1
down vote













n = 100;
m = 4;
list = Range[n];
s = RandomChoice[Range[m], n];

SparseArray[Transpose[s, list] -> _, m, n]["AdjacencyLists"]


Or slower, but easier to understand:



Lookup[GroupBy[Transpose[s, list], First -> Last], Range[m]]





share|improve this answer






















  • Is this supposed to spew errors in 11.3?
    – user6014
    2 hours ago










  • Ah, sorry. Please try again.
    – Henrik Schumacher
    2 hours ago










  • Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
    – ithilquessirr
    2 hours ago










  • Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
    – Henrik Schumacher
    1 hour ago

















up vote
1
down vote













Edit: I realized that my previous solution doesn't produce the same length partitions. Here is the desired solution.



s = RandomSample[Range@10, 10];
t = RandomSample@RandomChoice@IntegerPartitions[10, 4]
m, n, p, r = TakeList[s, t]

(*or m, n, p, r = FoldPairList[TakeDrop, s, t]*)



1, 5, 10, 3, 7, 2, 9, 6, 8, 4




Original answer:



s = RandomSample[Range@10, 10];
t = RandomSample[Range@4, 4];
m, n, p, r = FoldPairList[TakeDrop, s, t]



6, 2, 9, 5, 1, 7, 10, 3, 8, 4







share|improve this answer





























    up vote
    1
    down vote













    listz = CharacterRange["A", "K"];
    k = 4;

    SeedRandom[1]
    rc = RandomChoice[Range @ k, Length @ listz];
    m, n, p, r = Pick[listz, rc, #]& /@ Range[k];



    "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




    Also



    Lookup[GroupBy[Transpose[rc, listz], First -> Last], #, ]& /@ Range[k] 



    "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




    Update: To get k non-empty sublists:



    SeedRandom[1]
    rc = Module[r, While[Length[Counts[r = RandomChoice[Range@k, Length @ listz]]] < k]; r];
    Pick[listz , rc, # ] & /@ Range[k ]



    "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"




    Lookup[GroupBy[Transpose[rc , listz], First -> Last], #, ] & /@ Range[k] 



    "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"







    share|improve this answer






















      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.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      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',
      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
      );



      );






      ithilquessirr is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185296%2frandomly-distribute-numbers-to-lists%23new-answer', 'question_page');

      );

      Post as a guest






























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      on Mathematica 11.3



      (R=RandomSample)[Range@10,10]~TakeList~R@RandomChoice[Select[IntegerPartitions@10,Length@#==4&]] 





      Also I tried to fix your code



      a = ;
      b = ;
      c = ;
      d = ;
      Listz = a, b, c, d;
      Do[t=RandomChoice@Range@4;Listz[[t]]=AppendTo[Listz[[t]],i],i,1,10]
      Listz





      share|improve this answer






















      • Have you tried that with a list of 100 elements?
        – Henrik Schumacher
        1 hour ago










      • how about 10^100?
        – J42161217
        1 hour ago










      • @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
        – Okkes Dulgerci
        1 hour ago











      • @OkkesDulgerci fixed!
        – J42161217
        1 hour ago















      up vote
      2
      down vote













      on Mathematica 11.3



      (R=RandomSample)[Range@10,10]~TakeList~R@RandomChoice[Select[IntegerPartitions@10,Length@#==4&]] 





      Also I tried to fix your code



      a = ;
      b = ;
      c = ;
      d = ;
      Listz = a, b, c, d;
      Do[t=RandomChoice@Range@4;Listz[[t]]=AppendTo[Listz[[t]],i],i,1,10]
      Listz





      share|improve this answer






















      • Have you tried that with a list of 100 elements?
        – Henrik Schumacher
        1 hour ago










      • how about 10^100?
        – J42161217
        1 hour ago










      • @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
        – Okkes Dulgerci
        1 hour ago











      • @OkkesDulgerci fixed!
        – J42161217
        1 hour ago













      up vote
      2
      down vote










      up vote
      2
      down vote









      on Mathematica 11.3



      (R=RandomSample)[Range@10,10]~TakeList~R@RandomChoice[Select[IntegerPartitions@10,Length@#==4&]] 





      Also I tried to fix your code



      a = ;
      b = ;
      c = ;
      d = ;
      Listz = a, b, c, d;
      Do[t=RandomChoice@Range@4;Listz[[t]]=AppendTo[Listz[[t]],i],i,1,10]
      Listz





      share|improve this answer














      on Mathematica 11.3



      (R=RandomSample)[Range@10,10]~TakeList~R@RandomChoice[Select[IntegerPartitions@10,Length@#==4&]] 





      Also I tried to fix your code



      a = ;
      b = ;
      c = ;
      d = ;
      Listz = a, b, c, d;
      Do[t=RandomChoice@Range@4;Listz[[t]]=AppendTo[Listz[[t]],i],i,1,10]
      Listz






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 54 mins ago

























      answered 1 hour ago









      J42161217

      2,447218




      2,447218











      • Have you tried that with a list of 100 elements?
        – Henrik Schumacher
        1 hour ago










      • how about 10^100?
        – J42161217
        1 hour ago










      • @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
        – Okkes Dulgerci
        1 hour ago











      • @OkkesDulgerci fixed!
        – J42161217
        1 hour ago

















      • Have you tried that with a list of 100 elements?
        – Henrik Schumacher
        1 hour ago










      • how about 10^100?
        – J42161217
        1 hour ago










      • @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
        – Okkes Dulgerci
        1 hour ago











      • @OkkesDulgerci fixed!
        – J42161217
        1 hour ago
















      Have you tried that with a list of 100 elements?
      – Henrik Schumacher
      1 hour ago




      Have you tried that with a list of 100 elements?
      – Henrik Schumacher
      1 hour ago












      how about 10^100?
      – J42161217
      1 hour ago




      how about 10^100?
      – J42161217
      1 hour ago












      @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
      – Okkes Dulgerci
      1 hour ago





      @J42161217 Because Select[IntegerPartitions@10, Length@# == 4 &] sorted, you cannot get Lenght=1or 2 set for m.
      – Okkes Dulgerci
      1 hour ago













      @OkkesDulgerci fixed!
      – J42161217
      1 hour ago





      @OkkesDulgerci fixed!
      – J42161217
      1 hour ago











      up vote
      1
      down vote













      n = 100;
      m = 4;
      list = Range[n];
      s = RandomChoice[Range[m], n];

      SparseArray[Transpose[s, list] -> _, m, n]["AdjacencyLists"]


      Or slower, but easier to understand:



      Lookup[GroupBy[Transpose[s, list], First -> Last], Range[m]]





      share|improve this answer






















      • Is this supposed to spew errors in 11.3?
        – user6014
        2 hours ago










      • Ah, sorry. Please try again.
        – Henrik Schumacher
        2 hours ago










      • Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
        – ithilquessirr
        2 hours ago










      • Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
        – Henrik Schumacher
        1 hour ago














      up vote
      1
      down vote













      n = 100;
      m = 4;
      list = Range[n];
      s = RandomChoice[Range[m], n];

      SparseArray[Transpose[s, list] -> _, m, n]["AdjacencyLists"]


      Or slower, but easier to understand:



      Lookup[GroupBy[Transpose[s, list], First -> Last], Range[m]]





      share|improve this answer






















      • Is this supposed to spew errors in 11.3?
        – user6014
        2 hours ago










      • Ah, sorry. Please try again.
        – Henrik Schumacher
        2 hours ago










      • Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
        – ithilquessirr
        2 hours ago










      • Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
        – Henrik Schumacher
        1 hour ago












      up vote
      1
      down vote










      up vote
      1
      down vote









      n = 100;
      m = 4;
      list = Range[n];
      s = RandomChoice[Range[m], n];

      SparseArray[Transpose[s, list] -> _, m, n]["AdjacencyLists"]


      Or slower, but easier to understand:



      Lookup[GroupBy[Transpose[s, list], First -> Last], Range[m]]





      share|improve this answer














      n = 100;
      m = 4;
      list = Range[n];
      s = RandomChoice[Range[m], n];

      SparseArray[Transpose[s, list] -> _, m, n]["AdjacencyLists"]


      Or slower, but easier to understand:



      Lookup[GroupBy[Transpose[s, list], First -> Last], Range[m]]






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 1 hour ago

























      answered 2 hours ago









      Henrik Schumacher

      43.9k263129




      43.9k263129











      • Is this supposed to spew errors in 11.3?
        – user6014
        2 hours ago










      • Ah, sorry. Please try again.
        – Henrik Schumacher
        2 hours ago










      • Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
        – ithilquessirr
        2 hours ago










      • Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
        – Henrik Schumacher
        1 hour ago
















      • Is this supposed to spew errors in 11.3?
        – user6014
        2 hours ago










      • Ah, sorry. Please try again.
        – Henrik Schumacher
        2 hours ago










      • Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
        – ithilquessirr
        2 hours ago










      • Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
        – Henrik Schumacher
        1 hour ago















      Is this supposed to spew errors in 11.3?
      – user6014
      2 hours ago




      Is this supposed to spew errors in 11.3?
      – user6014
      2 hours ago












      Ah, sorry. Please try again.
      – Henrik Schumacher
      2 hours ago




      Ah, sorry. Please try again.
      – Henrik Schumacher
      2 hours ago












      Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
      – ithilquessirr
      2 hours ago




      Sorry, I couldn't understand what sparsearray function does here. But thanks this code is working.
      – ithilquessirr
      2 hours ago












      Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
      – Henrik Schumacher
      1 hour ago




      Well, you might inspect MatrixForm@Normal[SparseArray[Transpose[s, listz] -> _, mm, nn]] to find that out.
      – Henrik Schumacher
      1 hour ago










      up vote
      1
      down vote













      Edit: I realized that my previous solution doesn't produce the same length partitions. Here is the desired solution.



      s = RandomSample[Range@10, 10];
      t = RandomSample@RandomChoice@IntegerPartitions[10, 4]
      m, n, p, r = TakeList[s, t]

      (*or m, n, p, r = FoldPairList[TakeDrop, s, t]*)



      1, 5, 10, 3, 7, 2, 9, 6, 8, 4




      Original answer:



      s = RandomSample[Range@10, 10];
      t = RandomSample[Range@4, 4];
      m, n, p, r = FoldPairList[TakeDrop, s, t]



      6, 2, 9, 5, 1, 7, 10, 3, 8, 4







      share|improve this answer


























        up vote
        1
        down vote













        Edit: I realized that my previous solution doesn't produce the same length partitions. Here is the desired solution.



        s = RandomSample[Range@10, 10];
        t = RandomSample@RandomChoice@IntegerPartitions[10, 4]
        m, n, p, r = TakeList[s, t]

        (*or m, n, p, r = FoldPairList[TakeDrop, s, t]*)



        1, 5, 10, 3, 7, 2, 9, 6, 8, 4




        Original answer:



        s = RandomSample[Range@10, 10];
        t = RandomSample[Range@4, 4];
        m, n, p, r = FoldPairList[TakeDrop, s, t]



        6, 2, 9, 5, 1, 7, 10, 3, 8, 4







        share|improve this answer
























          up vote
          1
          down vote










          up vote
          1
          down vote









          Edit: I realized that my previous solution doesn't produce the same length partitions. Here is the desired solution.



          s = RandomSample[Range@10, 10];
          t = RandomSample@RandomChoice@IntegerPartitions[10, 4]
          m, n, p, r = TakeList[s, t]

          (*or m, n, p, r = FoldPairList[TakeDrop, s, t]*)



          1, 5, 10, 3, 7, 2, 9, 6, 8, 4




          Original answer:



          s = RandomSample[Range@10, 10];
          t = RandomSample[Range@4, 4];
          m, n, p, r = FoldPairList[TakeDrop, s, t]



          6, 2, 9, 5, 1, 7, 10, 3, 8, 4







          share|improve this answer














          Edit: I realized that my previous solution doesn't produce the same length partitions. Here is the desired solution.



          s = RandomSample[Range@10, 10];
          t = RandomSample@RandomChoice@IntegerPartitions[10, 4]
          m, n, p, r = TakeList[s, t]

          (*or m, n, p, r = FoldPairList[TakeDrop, s, t]*)



          1, 5, 10, 3, 7, 2, 9, 6, 8, 4




          Original answer:



          s = RandomSample[Range@10, 10];
          t = RandomSample[Range@4, 4];
          m, n, p, r = FoldPairList[TakeDrop, s, t]



          6, 2, 9, 5, 1, 7, 10, 3, 8, 4








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago

























          answered 2 hours ago









          Okkes Dulgerci

          3,4061716




          3,4061716




















              up vote
              1
              down vote













              listz = CharacterRange["A", "K"];
              k = 4;

              SeedRandom[1]
              rc = RandomChoice[Range @ k, Length @ listz];
              m, n, p, r = Pick[listz, rc, #]& /@ Range[k];



              "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




              Also



              Lookup[GroupBy[Transpose[rc, listz], First -> Last], #, ]& /@ Range[k] 



              "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




              Update: To get k non-empty sublists:



              SeedRandom[1]
              rc = Module[r, While[Length[Counts[r = RandomChoice[Range@k, Length @ listz]]] < k]; r];
              Pick[listz , rc, # ] & /@ Range[k ]



              "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"




              Lookup[GroupBy[Transpose[rc , listz], First -> Last], #, ] & /@ Range[k] 



              "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"







              share|improve this answer


























                up vote
                1
                down vote













                listz = CharacterRange["A", "K"];
                k = 4;

                SeedRandom[1]
                rc = RandomChoice[Range @ k, Length @ listz];
                m, n, p, r = Pick[listz, rc, #]& /@ Range[k];



                "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                Also



                Lookup[GroupBy[Transpose[rc, listz], First -> Last], #, ]& /@ Range[k] 



                "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                Update: To get k non-empty sublists:



                SeedRandom[1]
                rc = Module[r, While[Length[Counts[r = RandomChoice[Range@k, Length @ listz]]] < k]; r];
                Pick[listz , rc, # ] & /@ Range[k ]



                "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"




                Lookup[GroupBy[Transpose[rc , listz], First -> Last], #, ] & /@ Range[k] 



                "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"







                share|improve this answer
























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  listz = CharacterRange["A", "K"];
                  k = 4;

                  SeedRandom[1]
                  rc = RandomChoice[Range @ k, Length @ listz];
                  m, n, p, r = Pick[listz, rc, #]& /@ Range[k];



                  "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                  Also



                  Lookup[GroupBy[Transpose[rc, listz], First -> Last], #, ]& /@ Range[k] 



                  "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                  Update: To get k non-empty sublists:



                  SeedRandom[1]
                  rc = Module[r, While[Length[Counts[r = RandomChoice[Range@k, Length @ listz]]] < k]; r];
                  Pick[listz , rc, # ] & /@ Range[k ]



                  "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"




                  Lookup[GroupBy[Transpose[rc , listz], First -> Last], #, ] & /@ Range[k] 



                  "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"







                  share|improve this answer














                  listz = CharacterRange["A", "K"];
                  k = 4;

                  SeedRandom[1]
                  rc = RandomChoice[Range @ k, Length @ listz];
                  m, n, p, r = Pick[listz, rc, #]& /@ Range[k];



                  "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                  Also



                  Lookup[GroupBy[Transpose[rc, listz], First -> Last], #, ]& /@ Range[k] 



                  "C", "F", "G", "H", "K", "B", "D", "E", "I", , "A", "J"




                  Update: To get k non-empty sublists:



                  SeedRandom[1]
                  rc = Module[r, While[Length[Counts[r = RandomChoice[Range@k, Length @ listz]]] < k]; r];
                  Pick[listz , rc, # ] & /@ Range[k ]



                  "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"




                  Lookup[GroupBy[Transpose[rc , listz], First -> Last], #, ] & /@ Range[k] 



                  "A", "B", "C", "E", "H", "I", "F", "D", "G", "J", "K"








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 3 mins ago

























                  answered 52 mins ago









                  kglr

                  169k8192396




                  169k8192396




















                      ithilquessirr is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      ithilquessirr is a new contributor. Be nice, and check out our Code of Conduct.












                      ithilquessirr is a new contributor. Be nice, and check out our Code of Conduct.











                      ithilquessirr is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185296%2frandomly-distribute-numbers-to-lists%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Rj RNFWh8zEuTVsLnTnBP0N7D0uO CIQbO7dL0 AE8BzTWRfrbcyS
                      AjtXCCvUW,irbNaPMqXuQz9v1umpwxl,m4vJV7JXcVZZChhy E,Mj

                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      How many registers does an x86_64 CPU actually have?

                      Displaying single band from multi-band raster using QGIS