New answers tagged

2 votes

Sample integers that sum to one hundred

Vyxal W, 13 bytes ‹(₁ʀ℅)₁Ws₍h¯f choose cut positions and sort them, append 100 at the end, calculate the difference =>...
  • 1,407
2 votes

Sample integers that sum to one hundred

GolfScript, 42 bytes 100\(:a+,{;9.?rand}${a<}%1+{.1?.@@)>n\.}do Try it online! For some reason I just had to use GolfScript for this. No idea why though, I'...
  • 1,023
1 vote

Sample integers that sum to one hundred

Japt, 13 bytes î ÅiLî¬ ö¬¸mÊ Try it
  • 35.9k
3 votes

Sample integers that sum to one hundred

05AB1E, 9 bytes т∍ú¦.r#€g Inspired by @isaacg's Pyth answer, using @xnor's approach. Try it online or verify a few random outputs at once. Explanation: ...
1 vote

Sample integers that sum to one hundred

JavaScript (Node.js), 99 bytes f=(n,a=[100])=>--n?f(n,a.flatMap(v=>(s||s++)<p&&(s+=v)>p?[d=s-p|0,v-d]:v,p=Math.random(s=0)*101)):a Attempt This ...

Top 50 recent answers are included