Let's say we have some arbitrary number:
For example 25. We also have some "tokens" (poker chips, money, something similar) with different values.
Values of tokens are
2; 3; 4; 5.
"Tokens" are limitless
You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so.
Fragment of example expected output (25 with 8 tokens):
3 '5' tokens, 5 '2' tokens 2 '5' tokens, 1 '4' token, 1 '3' token, 4 '2' tokens .... 1 '4' token, 7 '3' tokens
You may output in any reasonable, non-ambiguous format. For instance, 3 '5' tokens, 5 '2' tokens can be represented as a single list [5,0,0,3] or as a list of tuples [[3,5],[5,2]]. And if there's no solution, you can provide empty output (or state
no solution found or something among the lines)
Standard code golf rules apply, so winner is decided by shortest byte count (though you have to also provide "commented" version of your code, especially for languages such as Brainfuck, Jelly, Piet and so on)
Edit: I intended this challenge as challenge with fixed tokens, but I like universal answers more then "niche" ones even if it's not specified in challenge itself initially. As long as making tokens "third input parameter" still provides correct answer for tokens provided it's accepted for this challenge. If you are willing to rewrite your code - go on, save those precious bytes/chars.