Tag Info

New answers tagged

2

Thread[{RandomSample[community[[#]], cant[[#]]], #}] & /@ Range[Length[community]] (* {{{2, 1}, {3, 1}, {5, 1}, {1, 1}, {4, 1}}, {{3, 2}}, {{2, 3}, {4, 3}}, {{3, 4}, {2, 4}, {1, 4}}, {{3, 5}, {5, 5}, {4, 5}, {1, 5}}} *)


2

{(community[[#]]~RandomSample~1)[[1]], #} & /@ ConstantArray[#, cant[[#]]] & /@ Range[Length@cant]


5

MapThread[Thread[List[RandomChoice[#1, #2], #3]] &, {community, cant, Range@Length@cant}] (* {{{2, 1}, {1, 1}, {3, 1}, {4, 1}, {6, 1}}, {{3, 2}}, {{4, 3}, {1, 3}}, {{2, 4}, {3, 4}, {1, 4}}, {{2, 5}, {3, 5}, {1, 5}, {6, 5}}} *) Some variations: MapIndexed[Thread[List[#1, First@#2]] &, MapThread[RandomChoice[#1, #2] &, {community, cant}]] ...



Top 50 recent answers are included