8
1
Write the shortest code you can solving the following problem:
Input:
An integer X with 2 <= X
and X <= 100
Output:
Total combinations of 2, 3, and 5 (repetition is allowed, order matters) whose sum is equal to X.
Examples:
Input: 8
Output: 6
, because the valid combinations are:
3+5
5+3
2+2+2+2
2+3+3
3+2+3
3+3+2
Input: 11
Output: 16
, because the valid combinations are
5+3+3
5+2+2+2
3+5+3
3+3+5
3+3+3+2
3+3+2+3
3+2+3+3
3+2+2+2+2
2+5+2+2
2+3+3+3
2+3+2+2+2
2+2+5+2
2+2+3+2+2
2+2+2+5
2+2+2+3+2
2+2+2+2+3
Input: 100
Output: 1127972743581281
, because the valid combinations are ... many
Input and output can be of any reasonable form. The lowest byte count in each language wins. Standard code-golf rules apply.
1
Welcome to PPCG! Unfortunately, here we don't answer general programming questions. However, you may be able to get help on [so]. Just be sure to check their help center out before asking. :)
– Erik the Outgolfer – 2018-02-16T17:23:38.9231Can someone reword this into a challenge? Because this would be a fun one. – Magic Octopus Urn – 2018-02-16T18:44:40.150
I was thinking the same, @MagicOctopusUrn, but then I got to wondering if it's not a dupe. – Shaggy – 2018-02-16T18:59:05.193
1@Shaggy Ugghhh... filtering through the challenges with the word
sum
in them was not a good idea to try to solve that inquiry... – Magic Octopus Urn – 2018-02-16T19:04:15.6002I rewrote your question a bit to make it better fit on codegolf. I also changed the result for input
11
from12
to16
. Of course feel free to fix this if I misunderstood your intention – Ton Hospel – 2018-02-16T19:38:20.803@TonHospel voted for your edit. – Magic Octopus Urn – 2018-02-16T19:39:57.660
I feel like we've had a challenge like this before, to express a number as a sum from a fixed set, maybe of coins. Don't know how I'd search for a potential dupe here. Anyone remember what I might be thinking of? – xnor – 2018-02-16T19:53:51.010
2
This is https://oeis.org/A079973
– Ton Hospel – 2018-02-16T20:22:30.953Borderline dupe of https://codegolf.stackexchange.com/q/85/194
– Peter Taylor – 2018-02-16T22:29:28.453