Skip to content

Instantly share code, notes, and snippets.

@codepunkt
Forked from cowboy/plus-brackets-only.js
Created June 1, 2011 20:22
Show Gist options
  • Save codepunkt/1003216 to your computer and use it in GitHub Desktop.
Save codepunkt/1003216 to your computer and use it in GitHub Desktop.
What results can you get just using these characters: +[]
// What results can you get just using these characters: +[]
// I know this has been done before, but I don't have the link,
// and I don't want it (not yet, at least)
// basic numbers
0: +[]
1: ++[+[]][+[]]
2: ++[++[+[]][+[]]][+[]]
3: ++[++[++[+[]][+[]]][+[]]][+[]]
4: ++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]
5: ++[++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]][+[]]
...
// add +[] at the end to coerce into string
'0': +[]+[]
'1': ++[+[]][+[]]+[]
'2': ++[++[+[]][+[]]][+[]]+[]
'3': ++[++[++[+[]][+[]]][+[]]][+[]]+[]
'4': ++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]+[]
'5': ++[++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]][+[]]+[]
...
// string concat (any number or string-of-a-number is clearly possible)
'10': ++[+[]][+[]]+[]+[+[]][+[]]
10: +[++[+[]][+[]]+[]+[+[]][+[]]][+[]]
11: ++[++[+[]][+[]]+[]+[+[]][+[]]][+[]]
...
// more goodies
'': []+[]
undefined: [][+[]]
'undefined': [][+[]]+[]
'u': [[]+[]+[][+[]]][+[]][+[]]
'n': [[]+[]+[][+[]]][+[]][++[+[]][+[]]]
'd': [[]+[]+[][+[]]][+[]][++[++[+[]][+[]]][+[]]]
'e': [[]+[]+[][+[]]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]
'f': [[]+[]+[][+[]]][+[]][++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]]
'i': [[]+[]+[][+[]]][+[]][++[++[++[++[++[+[]][+[]]][+[]]][+[]]][+[]]][+[]]]
NaN: +[][+[]]
'NaN': +[][+[]]+[]
'N': [+[][+[]]+[]][+[]][+[]]
'a': [+[][+[]]+[]][+[]][++[+[]][+[]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment