[Question]
  [
# Challenge
The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use addition or subtraction.
For example, if the input is 3, then there are 2 ways to make the sum 0: 
```
 1+2-3=0
-1-2+3=0
```
Note that, the numbers are in order, starting from 1 till n (which is 3 in this case). As it is evident from the example, the sign of the first number can also be negative, so be careful.
Now, 3 was pretty much simple. Let us list all the ways when we consider the number 7. 
```
 1+2-3+4-5-6+7=0
 1+2-3-4+5+6-7=0
 1-2+3+4-5+6-7=0
 1-2-3-4-5+6+7=0
-1+2+3+4+5-6-7=0
-1+2-3-4+5-6+7=0
-1-2+3+4-5-6+7=0
-1-2+3-4+5+6-7=0
```
So here, we have got a total of 8 possible ways. 
---
# Input And Output
As stated before, the **input would be a positive integer**. Your output should contain all the possible ways in which the numbers give a sum of zero. **In case there is no possible way** to do the same, **you can output anything** you like.
Also, **you can print the output in any format you like**. **But, it should be understandable**. For example, you may print it as in the above example. Or, you may just print the signs of the numbers in order. Otherwise, you can also print '0's and '1's in order, where '0' would display negative sign and '1' would display positive sign (or vice versa). 
For example, you can represent 1+2-3=0 using: 
```
1+2-3=0
1+2-3
[1,2,-3]
++-
110
001    
```
However, I would recommend using any of the first three formats for simplicity.
You can assume all the inputs to be valid. 
---
# Examples
```
7 ->
 1+2-3+4-5-6+7=0
 1+2-3-4+5+6-7=0
 1-2+3+4-5+6-7=0
 1-2-3-4-5+6+7=0
-1+2+3+4+5-6-7=0
-1+2-3-4+5-6+7=0
-1-2+3+4-5-6+7=0
-1-2+3-4+5+6-7=0
4 ->
 1-2-3+4=0
-1+2+3-4=0
2 -> -
8 ->
 1+2+3+4-5-6-7+8=0
 1+2+3-4+5-6+7-8=0
 1+2-3+4+5+6-7-8=0
 1+2-3-4-5-6+7+8=0
 1-2+3-4-5+6-7+8=0
 1-2-3+4+5-6-7+8=0
 1-2-3+4-5+6+7-8=0
-1+2+3-4+5-6-7+8=0
-1+2+3-4-5+6+7-8=0
-1+2-3+4+5-6+7-8=0
-1-2+3+4+5+6-7-8=0
-1-2+3-4-5-6+7+8=0
-1-2-3+4-5+6-7+8=0
-1-2-3-4+5+6+7-8=0
```
---
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code wins!
  
[Answer]
# [Haskell](https://www.haskell.org/), 42 bytes
```
f n=[l|l<-mapM(\i->[i,-i])[1..n],0==sum l]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hzzY6pybHRjc3scBXIyZT1y46U0c3M1Yz2lBPLy9Wx8DWtrg0VyEn9n9uYmaegq1CQVFmXomCikKagsl/AA "Haskell – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
1,-ṗ×RSÐḟ
```
[Try it online!](https://tio.run/##ARoA5f9qZWxsef//MSwt4bmXw5dSU8OQ4bif////NA "Jelly – Try It Online")
# Exp
```
1,-ṗ×RSÐḟ  Main link. Input = **n**. Assume n=2.
1,-        Literal list [1, -1].
   ṗ       Cartesian power **n**. Get [[1, 1], [1, -1], [-1, 1], [-1, -1]]
    ×R     Multiply (each list) by **R**ange 1..n.
       Ðḟ  **ḟ**ilter out lists with truthy (nonzero)
      S      **S**um.
```
---
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
[Jonathan Allan](https://codegolf.stackexchange.com/users/53748)'s suggestion, output a list of signs.
```
1,-ṗæ.ÐḟR
```
[Try it online!](https://tio.run/##ARoA5f9qZWxsef//MSwt4bmXw6Yuw5DhuJ9S////Nw "Jelly – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 62 bytes
```
f=lambda n,*l:f(n-1,n,*l)+f(n-1,-n,*l)if n else[l]*(sum(l)==0)
```
[Try it online!](https://tio.run/##JYxBCoAgEADP9QqPbhlktwJfEh2MtIR1C61Drzer2wwDc9zntlOXklWo/bxoRqLCwXJqpHgR6p@bT5xlxAxGM@JU8Xh5jqBUC8nuIRdHLGhaDZeih6EsjuDozMe8gPQA "Python 2 – Try It Online")
*Mr. Xcoder saved 4 bytes with a nifty use of starred arguments.*
[Answer]
# Perl, ~~37~~ 36 bytes
```
perl -E 'map eval||say,glob join"{+,-}",0..<>' <<< 7
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes
```
®X‚¹ãʒ¹L*O_
```
[Try it online!](https://tio.run/##AR0A4v8wNWFiMWX//8KuWOKAmsK5w6PKksK5TCpPX///Mw "05AB1E – Try It Online")
The output format for e.g. input `3` is:
```
[[-1, -1, 1], [1, 1, -1]]
```
That is, `-1-2+3, 1+2-3`.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 36 bytes
```
Pick[p={1,-1}~Tuples~#,p.Range@#,0]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@z8gMzk7usC22lBH17C2LqS0ICe1uE5Zp0AvKDEvPdVBWccgVu1/QFFmXkl0WrR5bOx/AA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 10 bytes
```
fo¬ΣΠmSe_ḣ
```
[Try it online!](https://tio.run/##yygtzv7/Py3/0Jpzi88tyA1OjX@4Y/H////NAQ "Husk – Try It Online")
## Explanation
Not too complicated.
```
fo¬ΣΠmSe_ḣ  Implicit input, say n=4
         ḣ  Range: [1,2,3,4]
     m      Map over the range:
      Se     pair element with
        _    its negation.
            Result: [[1,-1],[2,-2],[3,-3],[4,-4]]
    Π       Cartesian product: [[1,2,3,4],[1,2,3,-4],..,[-1,-2,-3,-4]]
f           Keep those
   Σ        whose sum
 o¬         is falsy (equals 0): [[-1,2,3,-4],[1,-2,-3,4]]
```
[Answer]
# [Python 3](https://docs.python.org/3/), 105 bytes
```
lambda n:[k for k in product(*[(1,-1)]*n)if sum(-~n*s for n,s in enumerate(k))==0]
from itertools import*
```
[Try it online!](https://tio.run/##Hc0xDoMwDEDRnVN4dCKQijpUQspJKENaEjWC2MgxA0uvnkL39/W3Qz9M9xrds64@v2YPNIwLRBZYIBFswvP@VrQj9m3Xm8mSSRHKnrH7ki1/SW25bKA9B/EacDHGudvUROEMSYMo83qavLGorVcjVxHxYYYGzksiRTH1Bw "Python 3 – Try It Online")
[Answer]
# [JavaScript (V8)](https://v8.dev/), ~~69 61~~ 58 bytes
*Saved 8 bytes thanks to @Neil*  
*Saved 3 bytes thanks to @l4m2*
Prints all solutions.
```
f=(n,o='')=>n?f(n-1,o+'+'+n)&f(n-1,o+-n):eval(o)||print(o)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEts/j/P81WI08n31ZdXdPWLs8@TSNP11AnX1sdCPM01WBc3TxNq9SyxByNfM2amoKizLwSIOt/cn5ecX5Oql5OfrqGgoJ6tHmsuqZ1moa5JheyjHpMXrQJRMYEU8YIImOEKWMBkbHQ/A8A "JavaScript (V8) – Try It Online")
[Answer]
# [Swift](https://swift.org), 116 bytes
```
func f(n:Int){var r=[[Int]()]
for i in 1...n{r=r.flatMap{[$0+[i],$0+[-i]]}}
print(r.filter{$0.reduce(0){$0+$1}==0})}
```
[Try it online!](https://tio.run/##NY5BCsIwFET3PUUoXSQ0hlQKSiUHcOEJYhalNvCh/pZvqouQs9cUcTU8mDfM6wM@tNvmVxyY59hdMYj47omRsTaD48IVfiYGDJA1SimMZEj5qQ@3fom20rUFJ/c4gHMpFQsBBp4rMIWRYqUVjY91GLkWGeqqScboJNL2n7Un2cqjPLv4U0Fm7wnYh5m6srtjKS77N8jOFw)
## Explanation
```
func f(n:Int){
  var r=[[Int]()]                         // Initialize r with [[]]
                                          // (list with one empty list)
  for i in 1...n{                         // For i from 1 to n:
    r=r.flatMap{[$0+[i],$0+[-i]]}         //   Replace every list in r with the list
  }                                       //   prepended with i and prepended with -i
  print(r.filter{$0.reduce(0){$0+$1}==0}) // Print all lists in r that sums to 0
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 91 bytes
```
lambda x:[s for s in[[~j*[1,-1][i>>j&1]for j in range(x)]for i in range(2**x)]if sum(s)==0]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCKrpYIS2/SKFYITMvOrouSyvaUEfXMDY6084uS80wFiSVBZRSKErMS0/VqNAEi2QiRIy0tICCmWkKxaW5GsWatrYGsf8LijLzShTSNMw1/wMA "Python 2 – Try It Online")
Returns a list of satisfying lists (e.g., f(3)=[[-1,-2,3], [1,2,-3]])
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 38 bytes
```
{k/⍨0=+/¨k←((,o∘.,⊢)⍣(⍵-1)⊢o←¯1 1)×⊂⍳⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TqbP1HvSsMbLX1D63IBvI1NHTyH3XM0NN51LVI81HvYo1HvVt1DTWBvHyg7KH1hgqGmoenP@pqetS7GShV@///o7aJaQrmXOq2trbqXGCOCTLHCJljAQA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), 13 bytes
```
f!sT.nM*F_BMS
```
**[Try it here!](https://pyth.herokuapp.com/?code=f%21sT.nM%2aF_BMS&input=4&debug=0)**
[Answer]
# [Clean](https://clean.cs.ru.nl), 79 bytes
```
import StdEnv
$n=[k\\k<-foldr(\i l=[[p:s]\\s<-l,p<-[~i,i]])[[]][1..n]|sum k==0]
```
[Try it online!](https://tio.run/##Jc27CsIwFIDh3afI0EGhKToJkmx2ELp1PDlD7EUOudKkgiA@urHg@C/fP9hJ@@LCuNqJOU2@kIthyazPY@ufu8pLMEoZwedgx2WviFkJEC8JlUqC2zoKDh@qCfEAgAinpvH4TqtjRsojlj7rjZOsYufyHWarH6nwW1euL68dDf/Ybh3dfw "Clean – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 73 bytes
```
.+
*
_
=_$`
+0`=
-$%"+
(-(_)+|\+(_)+)+
$&=$#2=$#3=
G`(=.+)\1=
=.*
_+
$.&
```
[Try it online!](https://tio.run/##K0otycxLNPz/X0@bS4srnss2XiWBS9sgwZZLV0VVSZtLQ1cjXlO7JkYbRGlqc6mo2aooGwGxsS2Xe4KGrZ62ZoyhLZetnhYXVzxQWk/t/39zAA "Retina – Try It Online") Explanation:
```
.+
*
```
Convert the input to unary.
```
_
=_$`
```
Convert the number to a list of `=`-prefixed numbers.
```
+0`=
-$%"+
```
Replace each `=` in turn with both `-` and `+`, duplicating the number of lines each time.
```
(-(_)+|\+(_)+)+
$&=$#2=$#3=
```
Separately count the number of `_`s after `-`s and `+`s. This sums the negative and positive numbers.
```
G`(=.+)\1=
```
Keep only those lines where the `-`s and `+`s cancel out.
```
=.*
```
Delete the counts.
```
_+
$.&
```
Convert to decimal.
[Answer]
# Python 3 + numpy, ~~104~~ 103 bytes
```
import itertools as I,numpy as P
lambda N:[r for r in I.product(*[[-1,1]]*N)if sum(P.arange(N)*r+r)==0]
```
Output is [-1, 1] corresponding to the sign.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~171~~ 161 bytes
* Saved ten bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat).
```
k,s;f(S,n,j)int*S;{if(s=j--)S[j]=~0,f(S,n,j),S[j]=1,f(S,n,j);else{for(k=n;k;)s+=k--*S[k];if(!s)for(puts("");k<n;)printf("%d",S[k++]+1);}}F(n){int S[n];f(S,n,n);}
```
[Try it online!](https://tio.run/##PY6xDsIgEIZfBWlMOIGkzCdrB1bGymBqMS16GtGp0VevaLTb3X35v/86fey6eU4qYxRekRphoPvG4zREke2oNfh2DPZVqz9X34NZduxPuZ/i5SaSJUwIWdqk9ca3KWCxrDJ84PVxz4JzwLQlhOut1ETB1wdefEnKIA3g89kIgqkg5lsKv5eogPm8H0g4@PY4W6Pbmtqgk3JR7aiqKkbMsvWBlZErB6opmZJ@Aw "C (gcc) – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~101~~ ~~100~~ 83 bytes
Represents addition as 0 and subtraction as 1, but that ultimately that does not matter since for any valid sequence, the complement of the sequence will also result in zero. Returns the permutations by appending them as 32-bit ints to a caller-provided buffer.
```
i,j,s;f(n,p)int*p;{for(i=1<<n;--i;s||(*p++=i))for(j=s=0;j<n;)s+=i>>j++&1?j:-j;n=p;}
```
[Try it online!](https://tio.run/##VVHLbsIwEDwnX7FKBeRZ4hJVFY7DrT8BqAqBgCMwURz6EOTXm64do7Y@eL07szP2uoj2RdH3PKxCSUtXhLXHRevX9FqeG5czkqaCRhGn8nZz/ToIGPc8BVVMsphWiHoSi1lWBcGYLKp5VFHBatr1D1wUx8t2B6lst/z8eMhs2eYtL6A4C9lCccgb8E2y4SJvvt4E32yOuyV5XgODq205MS4nBIeYGBOT66gJxBCIIZhcx0GBGAViFIhRIHcFQyCGYHIV7Y7ap5wL18Pb6JEIddlWMkJ1TNnLcAgCz7aQZGnGpVyqoq@2dQg4UAuhmpWuqoSIe1QVGmSXriPYiM9XAm0VrCE0A@3Gcc7AIYU6wjY8aidtpb3e8yMOSznytWr87RymiSAKmHMK@gLBzJsm9@KgNwhaf/8GYamk//2NsssySHyjOIb483VNQXcP7wHXGT36El8zcDKmPKfJQoVRMk80MDzT6tRWX1pl6U5WYqLLWO3srv8uymO@l3300Uen2dMP "C (gcc) – Try It Online")
# Explanation
```
i,j,s; // iterators i and j, sum s.
f(n,p)int*p; // declare function
{
  for ( i=1<<n; --i; // iterate over all permutations of n bits (except all-0)
      s||(*p++=i)) // if the permutation summed to 0, append it to the buffer 
   for(j=s=0;j<n;)
     s+= i>>j++&1 // Determine the value of the jth bit
       ?j:-j; // 1=>+(j+1), 0=>-(j+1)
  n=p; // return the pointer to the end of the appended values
}
```
[Answer]
# [Perl 6](https://perl6.org), 43 bytes
```
{grep *.sum==0,[X] (1..$_ X*1,-1).rotor(2)}
```
[Try it](https://tio.run/##NY7RCoIwGIXv9xTHEbWlLe0iArF6jCAq0lYY6samQYTPvpbVufu@H/5ztDTV0nVW4rEURUrqJ8aFukhk7nUzUmMqbFdnWRztdwewRIjRCbtpEs0SLoxqlWEL3jsxvpRWV@cnrsrg84CteEqI7XL8LwxbWza3SoLjRQDr3c@I@qzZx33jK9aIB9xsABqOTnSgIPD0hZ6Luyobvy63LZsfaUjn0QQT39q7Nw "Perl 6 – Try It Online")  
Returns a sequence of lists
## Expanded:
```
{  # bare block lambda with implicit parameter ｢$_｣
  grep              # only return the ones
    *.sum == 0,     # that sum to zero
    [X]             # reduce with cross meta operator
      (
          1 .. $_   # Range from 1 to the input
        X*          # cross multiplied by
          1, -1
      ).rotor(2)    # take 2 at a time (positive and negative)
}
```
`1..$_ X* 1,-1` ⇒ `(1, -1, 2, -2)`  
`(…).rotor(2)` ⇒ `((1, -1), (2, -2))`  
`[X] …` ⇒ `((1, 2), (1, -2), (-1, 2), (-1, -2))`
[Answer]
# [J](http://jsoftware.com/), 35 30 bytes
-5 bytes thanks to FrownyFrog! 
```
>:@i.(]#~0=1#.*"1)_1^2#:@i.@^]
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/7awcMvU0YpXrDGwNlfW0lAw14w3jjJRBog5xsf81uRS4UpMz8hXSFMwhDHV1mIAJuoARuoAF138A "J – Try It Online")
## Original:
# [J](http://jsoftware.com/), 35 bytes
```
[:(#~0=+/"1)>:@i.*"1(_1^[:#:@i.2^])
```
## How it works
I multiply the list 1..n with all possible lists of coefficients 1 / -1 and find the ones that add up to zero.
```
                    (             ) - the list of coefficients
                             i.     - list 0 to 
                               2^]  - 2 to the power of the input
                     _1^[:          - -1 to the power of 
                          #:@       - each binary digit of each number in 0..n-1 to 
                 *"1                - each row multiplied by
            >:@i.                   - list 1..n
  (#~      )                        - copy those rows
     0=+/"1                         - that add up to 0
[:                                  - compose   
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/o600lOsMbLX1lQw17awcMvW0lAw14g3joq2UQTyjuFjN/5pcClypyRn5CmkK5hCGujpMwARdwAhdwILrPwA "J – Try It Online")
As an alternative I tried an explicit verb, using the approach of cartesian product of +/-:
# [J](http://jsoftware.com/), 37 bytes
```
3 :'(#~0=+/"1)(-y)]\;{(<"1@,.-)1+i.y'
```
`{(<"1@,.-)` finds the cartesian products for example:
```
{(<"1@,.-) 1 2 3
┌───────┬────────┐
│1 2 3  │1 2 _3  │
├───────┼────────┤
│1 _2 3 │1 _2 _3 │
└───────┴────────┘
┌───────┬────────┐
│_1 2 3 │_1 2 _3 │
├───────┼────────┤
│_1 _2 3│_1 _2 _3│
└───────┴────────┘
```
Too bad that it boxes the result, so I spent some bytes to unbox the values
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/jRWs1DWU6wxstfWVDDU1dCs1Y2OsqzVslAwddPR0NQ21M/Uq1f9rcilwpSZn5CukKZhDGOrqMAETdAEjdAELrv8A "J – Try It Online")
[Answer]
Not the best but I tried :)
# C (Linux GCC)
## Entire program: 282 characters
```
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int n,x,i,s;int main(int c,char**z){n=atoi(z[1]);int a[n];for(x=0;x<n;x++)a[x]=x+1;for(i=0;i<pow(2, n)-1;i++){s=0;for(x=0;x<n;x++){printf("%c%d",i>>x&0x01?'-':'+',a[x]);s+=(i>>x&0x01?-1:1)*a[x];}printf(s!=0?"\r":"=%d \n",s);}}
```
## Just as function: 196 characters
```
void z(int n){int a[n],x,i,s;for(x=0;x<n;x++)a[x]=x+1;for(i=0;i<pow(2,n)-1;i++){s=0;for(x=0;x<n;x++){printf("%c%d",i>>x&0x01?'-':'+',a[x]);s+=(i>>x&0x01?-1:1)*a[x];}printf(s!=0?"\r":"=%d \n",s);}}
```
### Results
* n = 4:
```
+1-2-3+4=0 
-1+2+3-4=0
```
* n = 7:
```
+1-2-3-4-5+6+7=0 
-1+2-3-4+5-6+7=0 
-1-2+3+4-5-6+7=0 
+1+2-3+4-5-6+7=0 
-1-2+3-4+5+6-7=0 
+1+2-3-4+5+6-7=0 
+1-2+3+4-5+6-7=0 
-1+2+3+4+5-6-7=0
```
## Abstract Printing & Just Function: 172 characters
You could shrink the print statements down much more by simply outputting only the +/-'s which are represented by 1/-1 and abstractly representing the entire sum thing, but I still don't think it would beat the other C answers anyway.
That version is:
```
void z(int n){int a[n],x,i,j,s;for(x=0;x<n;x++)a[x]=x+1;for(i=0;i<pow(2,n)-1;i++){s=0;for(x=0;x<n;x++){j=i>>x&0x01?-1:1;printf("%d ",j);s+=j*a[x];}printf(s!=0?"\r":"\n");}}
```
## Results
* n = 4:
```
1 -1 -1 1 
-1 1 1 -1 
```
* n = 7:
```
1 -1 -1 -1 -1 1 1 
-1 1 -1 -1 1 -1 1  
-1 -1 1 1 -1 -1 1  
1 1 -1 1 -1 -1 1 
-1 -1 1 -1 1 1 -1 1 
1 1 -1 -1 1 1 -1 
1 -1 1 1 -1 1 -1 1 
-1 1 1 1 1 -1 -1 -1
```
[Answer]
# T-SQL, 152 bytes
Input is a *varchar(max)*
Output format is *+1+2-3*
```
WITH C as(SELECT @*1d,@+null o,0f
UNION ALL
SELECT~-d,concat(char(44+s),d,o),f+s*d
FROM C,(values(-1),(1))x(s)WHERE d>0)SELECT
o FROM C WHERE f=0and d=0
```
**[Try it online](https://data.stackexchange.com/stackoverflow/query/1255293/make-zero-from-first-n-numbers)**
[Answer]
# [R](https://www.r-project.org/), ~~82~~ 69 bytes
```
s=t(expand.grid(rep(list(c(-1,1)),n<-scan())))*1:n;t(s[,!colSums(s)])
```
[Try it online!](https://tio.run/##K/r/v9i2RCO1oiAxL0UvvSgzRaMotUAjJ7O4RCNZQ9dQx1BTUyfPRrc4OTFPQxMItAyt8qxLNIqjdRST83OCS3OLNYo1YzX/W/wHAA "R – Try It Online")
*Edit: -13 bytes by using built-in `expand.grid` function to automatically create matrix of all combinations of `+1` and `-1`.*
Selects rows of matrix of 1:n in all combinations of positive & negative which sum to zero.
Commented version:
```
s=t(                    # transpose matrix of:
mapply(rep,             # apply the function 'rep' 
    list(c(-1,1)),      # to the values (-1, 1)
    each=2^(0:(n-1)),   # repeating each by an increasing power-of-2
    length=2^n)         # and making the output length always 2^n
)                       # so: this generates a matrix of all the 
                        # combinations of -1 and 1
                        
t(                      # now transpose the matrix s
s[,                     # taking only the columns with a 
   !colSums(s*1:n)]     # zero sum of multiplying the values
)                       # by the sequence 1:n
```
**Previous (but sadly ~~longer~~ *much* longer) recursive strategy: 118 bytes**
```
f=function(n,l=NULL,t=0)`if`(n>1,c(f(n-1,c(0,l),t-n),f(n-1,c(1,l),t+n)),`if`(t==n,list(c(0,l)),if(t==-n)list(c(1,l))))
```
[Try it online!](https://tio.run/##XY7BCoMwEER/Zxc3oLdetl8gvXnWIi4E4wbS9eLPx8S2F@cy8JgZJuXtvS7jsaQ4SoobZ2HZdTYfFZQCv4a@J@MWJy8T6LOjGQTUVW8pIJlTpD/pLtIoIl15Yy4j/mPwTSN5qbB0frQ2im434IH5BA "R – Try It Online")
Outputs `1` for `+` and `0` for `-` (or the other way around).
Commented version:
```
f=function(n,l=NULL,t=0){               # n = counts down to 1 recursively
                                        # l = list of signs so far
                                        # t = total so far
    if(n==1){                           # if n is 1...
        if(t-n==0){                     # ...then if t-n makes zero...
            return(list(c("-",l))) }    # add a '-' to the list of signs & return it
        else if(t+n==0){                # ...or, if t+n makes zero...
            return(list(c("+",l))) }    # add a '+' to the list of signs & return it
        else {                          # ...otherwise we can't make zero...
            return(NULL) }              # so return NULL
    } else {                            # if n is greater than 1
        return(c(                       # return the result of calling this function
            f(n-1,c("-",l),t-n),        # using n-1, after applying either a '-'
            f(n-1,c("+",l),t+n)         # or a '+' and updating the total so far
        ))
    }
}
```
]