Permalink
Browse files

Create 2013-02-12-obfuscated-fibonacci.md

Obfuscated Fibonacci Sequence. Close #50

Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
  • Loading branch information...
1 parent 09b0f54 commit d28579005b953f3f8944e8b03917277bbebe5cf9 @s-m-k s-m-k committed with DTrejo Feb 12, 2013
Showing with 28 additions and 0 deletions.
  1. +28 −0 posts/2013-02-12-obfuscated-fibonacci.md
@@ -0,0 +1,28 @@
+```
+ var fib = function (_) {
+ for(_=[+[],++[[]][+[]],+[],_],_[++[++[++[[]][+[]]][+[]]][+[]]]=(((_[++[++[++[[]][+[]]][+[]]][+[]]]-(++[[]][+[]]))&(((--[[]][+[]])>>>(++[[]][+[]]))))===(_[++[++[++[[]][+[]]][+[]]][+[]]]-(++[[]][+[]])))?(_[++[++[[]][+[]]][+[]]]=++[[]][+[]],_[++[++[++[[]][+[]]][+[]]][+[]]]-(++[[]][+[]])):+[];_[++[++[++[[]][+[]]][+[]]][+[]]]--;_[+[]]=(_[++[[]][+[]]]=_[++[++[[]][+[]]][+[]]]=_[+[]]+_[++[[]][+[]]])-_[+[]]);
+ return _[++[++[[]][+[]]][+[]]];
+ }
+
+ console.assert(fib(-1) === 0);
+ console.assert(fib(0) === 0);
+ console.assert(fib(1) === 1);
+ console.assert(fib(2) === 1);
+ console.assert(fib(3) === 2);
+ console.assert(fib(4) === 3);
+ console.assert(fib(5) === 5);
+ console.assert(fib(6) === 8);
+ console.assert(fib(7) === 13);
+ console.assert(fib(32) === 2178309);
+ console.assert(fib(46) === 1836311903);
+ console.assert(fib(47) === 2971215073);
+ console.assert(fib(63) === 6557470319842);
+
+ console.log('done!');
+```
+
+I've combined (for fun) a few WTFs to make something bigger.
+
+Just in case... don't code in JS like that. Seriously.
+
+-- [@s3a](https://github.com/s3a/)

0 comments on commit d285790

Please sign in to comment.