4 kyu

Explosive Sum

2,998 of 8,874surtich

Description:

How many ways can you make the sum of a number?

From wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)

In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same partition. If order matters, the sum becomes a composition. For example, 4 can be partitioned in five distinct ways:

4
3 + 1
2 + 2
2 + 1 + 1
1 + 1 + 1 + 1

Examples

Basic

sum(1) // 1
sum(2) // 2  -> 1+1 , 2
sum(3) // 3 -> 1+1+1, 1+2, 3
sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

sum(10) // 42
explosiveSum  1   -- 1
explosiveSum 2   -- 2 -> 1+1 , 2
explosiveSum 3   -- 3 -> 1+1+1, 1+2, 3
explosiveSum 4   -- 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
explosiveSum 5   -- 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

explosiveSum 10  -- 42
exp_sum(1) # 1
exp_sum(2) # 2  -> 1+1 , 2
exp_sum(3) # 3 -> 1+1+1, 1+2, 3
exp_sum(4) # 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) # 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

exp_sum(10) # 42
exp_sum(1) # 1
exp_sum(2) # 2  -> 1+1 , 2
exp_sum(3) # 3 -> 1+1+1, 1+2, 3
exp_sum(4) # 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) # 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

exp_sum(10) # 42
exp_sum(1) // 1
exp_sum(2) // 2  -> 1+1 , 2
exp_sum(3) // 3 -> 1+1+1, 1+2, 3
exp_sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

exp_sum(10) // 42
ExpSum(1) // 1
ExpSum(2) // 2 -> 1+1 , 2
ExpSum(3) // 3 -> 1+1+1, 1+2, 3
ExpSum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
ExpSum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

ExpSum(10) // 42
exp_sum(1) // 1
exp_sum(2) // 2  -> 1+1 , 2
exp_sum(3) // 3 -> 1+1+1, 1+2, 3
exp_sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3

exp_sum(10) // 42

Explosive

sum(50) // 204226
sum(80) // 15796476
sum(100) // 190569292
explosiveSum  50 --    204226
explosiveSum  80 --  15796476
explosiveSum 100 -- 190569292
exp_sum(50) # 204226
exp_sum(80) # 15796476
exp_sum(100) # 190569292
exp_sum(50) # 204226
exp_sum(80) # 15796476
exp_sum(100) # 190569292
exp_sum(50) // 204226
exp_sum(80) // 15796476
exp_sum(100) // 190569292
ExpSum(50) // 204226
ExpSum(80) // 15796476
ExpSum(100) // 190569292
exp_sum(50) // 204226
exp_sum(80) // 15796476
exp_sum(100) // 190569292

See here for more examples.

Algorithms
Mathematics
Fundamentals

Stats:

CreatedJan 31, 2014
PublishedJan 31, 2014
Warriors Trained45324
Total Skips14832
Total Code Submissions42669
Total Times Completed8874
JavaScript Completions2998
Haskell Completions217
Ruby Completions295
Python Completions4304
C++ Completions980
Go Completions157
Rust Completions129
Total Stars1682
% of votes with a positive feedback rating90% of 928
Total "Very Satisfied" Votes769
Total "Somewhat Satisfied" Votes130
Total "Not Satisfied" Votes29
Ad
Contributors
  • surtich Avatar
  • jhoffner Avatar
  • xcthulhu Avatar
  • bkaes Avatar
  • Unnamed Avatar
  • GiacomoSorbi Avatar
  • jcsahnwaldt Avatar
  • JohanWiltink Avatar
  • Voile Avatar
  • FArekkusu Avatar
  • Awesome A.D. Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • sid114 Avatar
  • guuzaa Avatar
Ad