Skip to content

Instantly share code, notes, and snippets.

@Kuniwak
Last active August 29, 2015 13:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Kuniwak/9237578 to your computer and use it in GitHub Desktop.
クロノス・クラウン合同会社 柳井 政和さんの問題 「スーパー楕円のダンジョン」の回答。

コードの経過

Level 1

  • 118文字

    (Math.pow(Math.abs(x/32),3)+Math.pow(Math.abs(y/8),3)<=1)+2*(Math.pow(Math.abs(x/16),3)+Math.pow(Math.abs(y/16),3)<=1)
  • 90文字

    ((P=function P(a){return Math.pow(Math.abs(a),3)})(x/32)+P(y/8)<=1)+2*(P(x/16)+P(y/16)<=1)
  • 83文字

    ((P=function P(a){return b=a>0?a:-a,b*b*b})(x/32)+P(y/8)<=1)+2*(P(x/16)+P(y/16)<=1)
  • 76文字

    (X=x>0?x:-x,Y=y>0?y:-y,(X*X*X/32768+Y*Y*Y/512<=1)+2*((X*X*X+Y*Y*Y)/4096<=1))
  • 72文字

    (X=(x>0?x:-x)*x*x,Y=(y>0?y:-y)*y*y,(X/32768+Y/512<=1)+2*((X+Y)/4096<=1))
  • 70文字

    ((X=(x>0?x:-x)*x*x)/32768+(Y=(y>0?y:-y)*y*y)/512<=1)+2*((X+Y)/4096<=1)
  • 63文字

    ((X=(x>0?x:-x)*x*x)+(Y=(y>0?y:-y)*y*y)*64<=32768)+2*(X+Y<=4096)

Level 2

  • 69文字
((X=(1-(x<0)*2)*x*x*x)+(Y=(1-(y<0)*2)*y*y*y)*64<=32768)+2*(X+Y<=4096)

Level 3

これはひどいスパゲッティ

  • 199文字

    ((X=(c=(0+{}).constructor.fromCharCode,A=c(42),R=c(114,101,116,117,114,110,32),F=Function)(R+c(43+((x<0)<<1))+1+A+x+A+x+A+x)())+((Y=F(R+c(43+((y<0)<<1))+1+A+y+A+y+A+y)())<<6)<=32768)+((X+Y<=4096)<<1)

反省

  • 再帰も選択肢に入れる

  • parseInt をうまくつかう(参考

    【加算をループ処理】

    console.log(x=5, (function(){r=0;for(c=x;c;c--)for(d=x;d;d--)r+=x;return r})());
    console.log(x=5, (f=function(n,c){r=0;for(;c;c--)r+=n;return r})(x,f(x,x)));

    【加算を再帰処理】

    console.log(x=5, (f=function(n,c){return --c?f(n,c)+n:n})(x,f(x,x)));

    【進数変換を利用】

    console.log(x=5, parseInt(1000,x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment