Skip to main content
6 votes

Create sublists whose totals exceed a certain threshold and that are as short as possible

Why not just use Most: ...
ydd's user avatar
  • 4,132
3 votes

Create sublists whose totals exceed a certain threshold and that are as short as possible

I may have misunderstood but this finds shortest subset satisfying constraint: ...
ubpdqn's user avatar
  • 62.1k
3 votes

Create sublists whose totals exceed a certain threshold and that are as short as possible

Assume what you want is just one instance of shortest consecutive sequence of the elements in the list. Then following pattern matching will help you: ...
A. Kato's user avatar
  • 741
2 votes

Is there a better way to " Select non self mapping elements from a list of rules"?

DeleteCases[abc, Rule[x_, x_]] {b -> c, e -> f}
A. Kato's user avatar
  • 741
2 votes

Is there a better way to " Select non self mapping elements from a list of rules"?

abc = {a -> a, b -> c, d -> d, e -> f}; Using Pick and UnsameQ ...
eldo's user avatar
  • 78.1k
2 votes

Create sublists whose totals exceed a certain threshold and that are as short as possible

list = {2, 1, 8, 10, 1, 4, 4, 5, 3, 4, 4, 11, 12}; th = 10; f = SequenceCases[#, {a___, e_} /; ! Max@Accumulate@{a} > th :> {a, e}] &; f@list ...
vindobona's user avatar
  • 4,941
1 vote

Create sublists whose totals exceed a certain threshold and that are as short as possible

list = {2, 1, 8, 10, 1, 4, 4, 5, 3, 4, 4, 11, 12}; th = 10; A more programmatic way to do it is the following: ...
E. Chan-López's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible