2 added 207 characters in body
source | link

Husk, 10 bytes

ηλfo=¹ṁ⁰tṖ

1-indexed. Try it online!

Explanation

This uses the latest addition to Husk, η (act on indices). I'll add a more detailed explanation on it later, as the usage here may be somewhat counter-intuitive.

ηλfo=¹ṁ⁰tṖ  Inputs are a number n (explicit, accessed with ¹) and a list x (implicit).
η           Act on the incides of x
 λ          using this function:
         Ṗ   Take all subsets,
        t    remove the first one (the empty subset),
  f          and keep those that satisfy this:
      ṁ⁰      The sum of the corresponding elements of x
   o=¹        equals n.

This uses the latest addition to Husk, η (act on indices). The idea is that η takes a higher order function α (here the inline lambda function) and a list x, and calls α on the indexing function of x (which is in the above program) and the indices of x. For example, ṁ⁰ takes a subset of indices, maps indexing to x over them and sums the results.

Husk, 10 bytes

ηλfo=¹ṁ⁰tṖ

1-indexed. Try it online!

Explanation

This uses the latest addition to Husk, η (act on indices). I'll add a more detailed explanation on it later, as the usage here may be somewhat counter-intuitive.

ηλfo=¹ṁ⁰tṖ  Inputs are a number n (explicit, accessed with ¹) and a list x (implicit).
η           Act on the incides of x
 λ          using this function:
         Ṗ   Take all subsets,
        t    remove the first one (the empty subset),
  f          and keep those that satisfy this:
      ṁ⁰      The sum of the corresponding elements of x
   o=¹        equals n.

Husk, 10 bytes

ηλfo=¹ṁ⁰tṖ

1-indexed. Try it online!

Explanation

ηλfo=¹ṁ⁰tṖ  Inputs are a number n (explicit, accessed with ¹) and a list x (implicit).
η           Act on the incides of x
 λ          using this function:
         Ṗ   Take all subsets,
        t    remove the first one (the empty subset),
  f          and keep those that satisfy this:
      ṁ⁰      The sum of the corresponding elements of x
   o=¹        equals n.

This uses the latest addition to Husk, η (act on indices). The idea is that η takes a higher order function α (here the inline lambda function) and a list x, and calls α on the indexing function of x (which is in the above program) and the indices of x. For example, ṁ⁰ takes a subset of indices, maps indexing to x over them and sums the results.

1
source | link

Husk, 10 bytes

ηλfo=¹ṁ⁰tṖ

1-indexed. Try it online!

Explanation

This uses the latest addition to Husk, η (act on indices). I'll add a more detailed explanation on it later, as the usage here may be somewhat counter-intuitive.

ηλfo=¹ṁ⁰tṖ  Inputs are a number n (explicit, accessed with ¹) and a list x (implicit).
η           Act on the incides of x
 λ          using this function:
         Ṗ   Take all subsets,
        t    remove the first one (the empty subset),
  f          and keep those that satisfy this:
      ṁ⁰      The sum of the corresponding elements of x
   o=¹        equals n.