Skip to main content
Became Hot Network Question
added 10 characters in body
Source Link
licheng
  • 2.1k
  • 1
  • 9
  • 17

I looked at three answers, including the previous ones, andbut Syed and I just noticed that running Subsets[Range[n]] when $n$ is large first seems to take up a lot of memory. I hope I haven’t misunderstood. If that's the case, it goes against my original intention.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

I looked at three answers, including the previous ones, and I just noticed that running Subsets[Range[n]] when $n$ is large first seems to take up a lot of memory. I hope I haven’t misunderstood. If that's the case, it goes against my original intention.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

I looked at three answers, including the previous ones, but Syed and I just noticed that running Subsets[Range[n]] when $n$ is large first seems to take up a lot of memory. I hope I haven’t misunderstood. If that's the case, it goes against my original intention.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

added 262 characters in body
Source Link
licheng
  • 2.1k
  • 1
  • 9
  • 17

I looked at three answers, including the previous ones, and I just noticed that running Subsets[Range[n]] when $n$ is large first seems to take up a lot of memory. I hope I haven’t misunderstood. If that's the case, it goes against my original intention.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

I looked at three answers, including the previous ones, and I just noticed that running Subsets[Range[n]] when $n$ is large first seems to take up a lot of memory. I hope I haven’t misunderstood. If that's the case, it goes against my original intention.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

added 5 characters in body
Source Link
licheng
  • 2.1k
  • 1
  • 9
  • 17

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer. I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets   s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer. I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

For example, I only want to find 5 subsets s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

Earlier, in the question, we inquired about finding all the subsets that meet the desired conditions, and Daniel Huber provided an answer.

d = Subsets[Range[6]];
Reap[
  Scan[(If[Total[#] > 15, Sow[#]]) &, d]][[2]]

I'm now wondering if, instead of retrieving all the valid subsets, we only need to find the first $k$ subsets and stop once they are found.

For example, I only want to find 5 subsets   s such that Total[s] > 15. The premise remains to avoid generating all subsets at once, considering memory usage.

Source Link
licheng
  • 2.1k
  • 1
  • 9
  • 17
Loading