Created
May 18, 2012 02:13
-
-
Save chrisinajar/2722736 to your computer and use it in GitHub Desktop.
javascript fizzbuzz solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize string override sequence | |
var j,sp = { | |
s: String.prototype.toString, | |
l: function(){console.log(this.s());} | |
}, d=['F','B'], fd=function(l) {sp[l]=function(){return l+this;};}; | |
// splines.reticulate | |
fd(d[0]); | |
fd(d[1]); | |
for(j in sp) | |
String.prototype[j] = sp[j]; | |
// spin the flux capaciter | |
var s=1,e=100,i="izz",u="uzz"; | |
for(j=s;j<e+1;++j) { | |
var rs = j; | |
while(rs>9) | |
for (var k=0,sr=rs.toString(),rs=0;k<sr.length;++k) { | |
rs+=parseInt(sr[k],10); | |
} | |
(function(j, i, u) { | |
if (/[369]/.exec(rs)) return u.F()+(/[05]$/.exec(j)?i.B():''); | |
else if (j%5===0) return i.B(); | |
else return j.toString(); | |
})(j, u, i).l(); | |
} |
Wow. Win.
Wow, this is a very easy to read.
Yeah, I even commented the code.
Reticulating Splines...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var j,sp={s:String.prototype.toString,l:function(){console.log(this.s());}},d=['F','B'],fd=function(l){sp[l]=function(){return l+this;};};fd(d[0]);fd(d[1]);for(j in sp)
String.prototype[j]=sp[j];var s=1,e=100,i="izz",u="uzz";for(j=s;j<e+1;++j){var rs=j;while(rs>9)
for(var k=0,sr=rs.toString(),rs=0;k<sr.length;++k){rs+=parseInt(sr[k],10);}
(function(j,i,u){if(/[369]/.exec(rs))return u.F()+(/[05]$/.exec(j)?i.B():'');else if(j%5===0)return i.B();else return j.toString();})(j,u,i).l();}