Skip to main content
Post Closed as "Duplicate" by Mr.Wizard
deleted 1 character in body
Source Link

Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this:

r = {4,5,6} ord = Range[15] a = RandomSample[ord] 

And though for everyone the evaluation would yield a randomly different answer each time, for me the answer was:

{4,5,6} {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {13,2,8,15,7,12,14,3,11,1,6,5,9,4,10} 

Now, half of the challenge I'm stuck on is how to Partition "a" (the last line of the output above) in the consecutive amounts of the set "r" ({4,5,6}), such that the output next would look like:

{{1013,2,8,1415},{127,1112,54,3,1311},{15,91,6,15,79,4,10}} // Lengths 4,5,6 respectively 

Lastly I want the Ordering function applied to each of these subsets in one fell stroke, so that the final output derived from the above line would be:

{{2,3,1,2,4},{4,3,2,1,5,2},{61,5,3,12,4,26}} 

Of course the answer would look different depending on what random sample was generated, but I need the logic to be consistent with what's here outlined.

Thanks!

Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this:

r = {4,5,6} ord = Range[15] a = RandomSample[ord] 

And though for everyone the evaluation would yield a randomly different answer each time, for me the answer was:

{4,5,6} {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {13,2,8,15,7,12,14,3,11,1,6,5,9,4,10} 

Now, half of the challenge I'm stuck on is how to Partition "a" (the last line of the output above) in the consecutive amounts of the set "r" ({4,5,6}), such that the output next would look like:

{{10,2,8,14},{12,11,5,3,13},{15,9,6,1,7,4}} // Lengths 4,5,6 respectively 

Lastly I want the Ordering function applied to each of these subsets in one fell stroke, so that the final output derived from the above line would be:

{{3,1,2,4},{4,3,2,1,5},{6,5,3,1,4,2}} 

Of course the answer would look different depending on what random sample was generated, but I need the logic to be consistent with what's here outlined.

Thanks!

Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this:

r = {4,5,6} ord = Range[15] a = RandomSample[ord] 

And though for everyone the evaluation would yield a randomly different answer each time, for me the answer was:

{4,5,6} {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {13,2,8,15,7,12,14,3,11,1,6,5,9,4,10} 

Now, half of the challenge I'm stuck on is how to Partition "a" (the last line of the output above) in the consecutive amounts of the set "r" ({4,5,6}), such that the output next would look like:

{{13,2,8,15},{7,12,4,3,11},{1,6,5,9,4,10}} // Lengths 4,5,6 respectively 

Lastly I want the Ordering function applied to each of these subsets in one fell stroke, so that the final output derived from the above line would be:

{{2,3,1,4},{4,3,1,5,2},{1,5,3,2,4,6}} 

Of course the answer would look different depending on what random sample was generated, but I need the logic to be consistent with what's here outlined.

Thanks!

Source Link

Non-Constant Partitioning of a List with Order Analysis

Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this:

r = {4,5,6} ord = Range[15] a = RandomSample[ord] 

And though for everyone the evaluation would yield a randomly different answer each time, for me the answer was:

{4,5,6} {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {13,2,8,15,7,12,14,3,11,1,6,5,9,4,10} 

Now, half of the challenge I'm stuck on is how to Partition "a" (the last line of the output above) in the consecutive amounts of the set "r" ({4,5,6}), such that the output next would look like:

{{10,2,8,14},{12,11,5,3,13},{15,9,6,1,7,4}} // Lengths 4,5,6 respectively 

Lastly I want the Ordering function applied to each of these subsets in one fell stroke, so that the final output derived from the above line would be:

{{3,1,2,4},{4,3,2,1,5},{6,5,3,1,4,2}} 

Of course the answer would look different depending on what random sample was generated, but I need the logic to be consistent with what's here outlined.

Thanks!