Skip to main content
deleted 4 characters in body
Source Link
Unrelated String
  • 23k
  • 3
  • 32
  • 55

Jelly, 11 bytes

’Ø-ṗÄS=¥ƇḢŻ

Try it online!

Although I originally had ’2*ḶBz0Z-*ÄS=¥ƇḢŻ, this is close enough to caird's solution in principle now that I'm almost tempted to just suggest it in the comments. In the case that you really really want [] over 0, maybe it's just +4 bytes?maybe it's just +3 bytes?, maybe it's +6maybe it's +5.

 Ø-            [-1, 1]
   ṗ           to the Cartesian power of
’              n - 1.
    Ä          Cumulative sums.
        Ƈ      Keep only those for which
     S ¥       the sum
      =        is equal to s.
         Ḣ     Take the first survivor
          Ż    and slap a 0 on the start of it.

Jelly, 11 bytes

’Ø-ṗÄS=¥ƇḢŻ

Try it online!

Although I originally had ’2*ḶBz0Z-*ÄS=¥ƇḢŻ, this is close enough to caird's solution in principle now that I'm almost tempted to just suggest it in the comments. In the case that you really really want [] over 0, maybe it's just +4 bytes?, maybe it's +6.

 Ø-            [-1, 1]
   ṗ           to the Cartesian power of
’              n - 1.
    Ä          Cumulative sums.
        Ƈ      Keep only those for which
     S ¥       the sum
      =        is equal to s.
         Ḣ     Take the first survivor
          Ż    and slap a 0 on the start of it.

Jelly, 11 bytes

’Ø-ṗÄS=¥ƇḢŻ

Try it online!

Although I originally had ’2*ḶBz0Z-*ÄS=¥ƇḢŻ, this is close enough to caird's solution in principle now that I'm almost tempted to just suggest it in the comments. In the case that you really really want [] over 0, maybe it's just +3 bytes?, maybe it's +5.

 Ø-            [-1, 1]
   ṗ           to the Cartesian power of
’              n - 1.
    Ä          Cumulative sums.
        Ƈ      Keep only those for which
     S ¥       the sum
      =        is equal to s.
         Ḣ     Take the first survivor
          Ż    and slap a 0 on the start of it.
Source Link
Unrelated String
  • 23k
  • 3
  • 32
  • 55

Jelly, 11 bytes

’Ø-ṗÄS=¥ƇḢŻ

Try it online!

Although I originally had ’2*ḶBz0Z-*ÄS=¥ƇḢŻ, this is close enough to caird's solution in principle now that I'm almost tempted to just suggest it in the comments. In the case that you really really want [] over 0, maybe it's just +4 bytes?, maybe it's +6.

 Ø-            [-1, 1]
   ṗ           to the Cartesian power of
’              n - 1.
    Ä          Cumulative sums.
        Ƈ      Keep only those for which
     S ¥       the sum
      =        is equal to s.
         Ḣ     Take the first survivor
          Ż    and slap a 0 on the start of it.