Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 26956

this tag is used for questions regarding splitting a list into sublists

2 votes

Cluster numbers into n partitions so that each partitions sum is closest to total/n

Here's an overengineered approach using the method of simulated annealing. I apologize for the poor style of coding, this is something I had lying around found somewhere online and modified just now f …
LLlAMnYP's user avatar
  • 11.5k
4 votes

Any alternative way to compute IntegerPartitions?

Here is a combination of @ciao's suggesting and @yarchik's comment: assoc = <||>; max = 70; step = 10000; Do[assoc = Merge[ {assoc, Counts[Flatten[ IntegerPartitions[max, All, …
LLlAMnYP's user avatar
  • 11.5k
1 vote

Find all the possible ways of partitioning a list into a set of pairs of element

Possibly similar to the solution in the comments. list = {x1, x1, x3, x4}; Map[list[[#]] &, DeleteDuplicates[ Map[Sort, Partition[#, 2] & /@ Permutations[Range[Length@list]], 2]], {2}] {{{ …
LLlAMnYP's user avatar
  • 11.5k
2 votes

Need Help Writing code to find Capparelli Partitions

Instead of running Select[IntegerPartitions[n - i s], AllTrue[#, # < s &] &] it would be much better to generate here only those partitions of n - i s whose biggest addend is smaller than s. … = kMinAddendsS[n, s, k]}, partitions = Select[partitions, testDiff2[#, dist, diff] &]; partitions = Select[partitions, testMod2[#, d, c, M, m] &] ] The capparelliPartitions function includes some …
LLlAMnYP's user avatar
  • 11.5k
5 votes

Find all the possible ways of partitioning a list into a set of pairs of element

Take the first element and pair it with the second, find all partitions of the remaining elements (3 to n). Append the 1st and 2nd element to these partitions. …
LLlAMnYP's user avatar
  • 11.5k
5 votes

How to Map a subset of list elements to a function?

It's strange, that ListCorrelate has not been mentioned, according to the documentation, it has been around unchanged since v.4.0. It allows a one liner: ListCorrelate[{1, 1}, Range@9, {1, -1}, {}, T …
LLlAMnYP's user avatar
  • 11.5k