Skip to content

Instantly share code, notes, and snippets.

@chrisinajar
Created May 18, 2012 02:13
Show Gist options
  • Save chrisinajar/2722736 to your computer and use it in GitHub Desktop.
Save chrisinajar/2722736 to your computer and use it in GitHub Desktop.
javascript fizzbuzz solution
// 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();
}
@devnill
Copy link

devnill commented May 18, 2012

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();}

@Benhgift
Copy link

Wow. Win.

@tyrelsouza
Copy link

Wow, this is a very easy to read.

@chrisinajar
Copy link
Author

Yeah, I even commented the code.

@Benhgift
Copy link

Reticulating Splines...

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