Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created May 21, 2011 21:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cowboy/984932 to your computer and use it in GitHub Desktop.
Save cowboy/984932 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': [+[][+[]]+[]][+[]][++[+[]][+[]]]
@rwaldron
Copy link

(also) NaN: +[][[]]

Beyond what's here, I think you need () to get "Infinity" (As I vaguely recall from that listing, which I also can't find :\ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment