Created
October 20, 2011 06:07
-
-
Save mururu/1300533 to your computer and use it in GitHub Desktop.
KawaduFuck
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
window.onload = function(){ | |
var ptr = 0; | |
var mem = []; | |
var count = 1; | |
var input_set = function(input) { | |
var splited = input.split(' '); | |
var ary = []; | |
for(var i = 0, len = splited.length; i < len; ){ | |
ary.push(splited[i++] + splited[i++]); | |
} | |
return ary; | |
}; | |
var eval_ary = function(ary){ | |
var output = ""; | |
for(var a_ptr = 0; a_ptr < ary.length; a_ptr++){ | |
switch(ary[a_ptr]) { | |
case "生まれた時から圏論を理解しているかわず大先生": | |
ptr++; | |
break; | |
case "モジュライの専門家かわず大先生": | |
ptr--; | |
break; | |
case "得意のフランス語を駆使してEGAとSGAを全訳しているかわず大先生": | |
if(++mem[ptr] == 256) mem[ptr] = 0; | |
break; | |
case "線形代数の快男児かわず大先生": | |
if(--mem[ptr] == -1) mem[ptr] = 255; | |
break; | |
case "かわず大先生生まれた時から圏論を理解している": | |
output += String.fromCharCode(mem[ptr]); | |
break; | |
case "かわず大先生モジュライの専門家": | |
chr = window.prompt("かわず大先生", ""); | |
mem[ptr] = chr.charCodeAt(0); | |
break; | |
case "かわず大先生得意のフランス語を駆使してEGAとSGAを全訳している": | |
count = 1; | |
if(!mem[ptr]){ | |
while(count){ | |
a_ptr++; | |
if(ary[a_ptr] == "かわず大先生得意のフランス語を駆使してEGAとSGAを全訳している"){ | |
count++; | |
} | |
if(ary[a_ptr] == "かわず大先生線形代数の快男児"){ | |
count--; | |
} | |
} | |
} | |
break; | |
case "かわず大先生線形代数の快男児": | |
count = 1; | |
if(mem[ptr]){ | |
while(count){ | |
a_ptr--; | |
if(ary[a_ptr] == "かわず大先生得意のフランス語を駆使してEGAとSGAを全訳している"){ | |
count--; | |
} | |
if(ary[a_ptr] == "かわず大先生線形代数の快男児"){ | |
count++; | |
} | |
} | |
a_ptr--; | |
} | |
break; | |
} | |
} | |
return output; | |
}; | |
document.getElementById('btn').addEventListener('click', function() { | |
ptr = 0; | |
mem = []; | |
for(var j = 0; j < 255; j++){ | |
mem[j] = 0; | |
} | |
var input = document.getElementById('in'); | |
var output = document.getElementById('out'); | |
var ary = input_set(input.value); | |
output.value = eval_ary(ary); | |
}, false); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment