Skip to main content
2 bytes golfed thanks to J42161217
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41

Wolfram Language (Mathematica), 56 49 46 4343 41 bytes

2 bytes golfed thanks to J42161217

f[n_,a_]=If[n<=0n_~f~a_=If[n<1,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!Try it online!

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 43 bytes

f[n_,a_]=If[n<=0,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 43 41 bytes

2 bytes golfed thanks to J42161217

n_~f~a_=If[n<1,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

deleted 58 characters in body
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41

Wolfram Language (Mathematica), 56 49 46 43 bytes

f[n_,a_]=If[n<=0,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

This borrows the method used by Arnauld's answer.

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 43 bytes

f[n_,a_]=If[n<=0,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

This borrows the method used by Arnauld's answer.

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 43 bytes

f[n_,a_]=If[n<=0,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Boole[n==0] → 1+Sign@n
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41

Wolfram Language (Mathematica)Wolfram Language (Mathematica), 56 49 4646 43 bytes

f[n_,a_]=If[n<=0,Boole[n==0]1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!Try it online!

This borrows the method used by Arnauld's answer.

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 bytes

f[n_,a_]=If[n<=0,Boole[n==0],Tr[f[n-#,a]&/@a]] 

Try it online!

This borrows the method used by Arnauld's answer.

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

Wolfram Language (Mathematica), 56 49 46 43 bytes

f[n_,a_]=If[n<=0,1+Sign@n,Tr[f[n-#,a]&/@a]] 

Try it online!

This borrows the method used by Arnauld's answer.

Initial solution:

Length[Join@@Permutations/@IntegerPartitions[#,∞,#2]]& 

Try it online!

changed Total to Tr
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41
Loading
shorter answer
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41
Loading
Source Link
DanTheMan
  • 4.1k
  • 17
  • 41
Loading