Last active
August 29, 2015 14:18
-
-
Save ww24/1bfe6cce77829d3a483d to your computer and use it in GitHub Desktop.
Application Developer Festival 2015. Short coding. JavaScript部門 2 位. AtCoder System:JavaScript (Node.js 0.6.12)
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
/** | |
問題 | |
入力: なし | |
出力: | |
高橋一郎 | |
高橋二郎 | |
高橋三郎 | |
高橋四郎 | |
高橋五郎 | |
高橋六郎 | |
高橋七郎 | |
高橋八郎 | |
高橋九郎 | |
高橋十郎 | |
*/ | |
// 提出コード (89 Byte) | |
for(i=0;i<10;)console.log("高橋"+"一二三四五六七八九十".split("")[i++]+"郎") | |
// あとで考えた最短コード (77 Byte) | |
for(i=10;i;)console.log("高橋"+"十九八六七五四三二一"[--i]+"郎") |
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
/** | |
問題 | |
入力: 整数 N (1≦N≦100000) | |
出力: N 以下の素数の数 | |
*/ | |
// 提出コード (135 Byte) | |
N=+require("fs").readFileSync("/dev/stdin"),p=[] | |
for(x=2;x<=N;x++)if(p.every(function(y){return x%y}))p.push(x) | |
console.log(p.length) |
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
/** | |
問題 | |
入力: | |
1 行目 : 奇数 N (1≦N<1000) | |
1+N 行目: 整数 Ci (1≦ci≦100000000), i≠j のとき Ci≠Cj | |
出力: Ci の中央値 (ソートして中央の値) | |
*/ | |
// 提出コード (135 Byte) | |
n=(require("fs").readFileSync("/dev/stdin")+"").trim().split("\n") | |
console.log(n.slice(1).sort(function(a,b){return a-b})[~~(n[0]/2)]) | |
// あとで考えた最短コード (131 Byte) | |
n=(require("fs").readFileSync("/dev/stdin")+"").trim().split("\n");console.log(n.slice(1).sort(function(a,b){return a-b})[n[0]/2|0]) |
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
/** | |
問題 | |
入力: 整数 N (0≦N≦9) | |
出力: 7セグ LED の点灯パターン (左から 0 ~ 9) | |
□■■■□ □□□□□ □■■■□ □■■■□ □□□□□ □■■■□ □■■■□ □■■■□ □■■■□ □■■■□ | |
■□□□■ □□□□■ □□□□■ □□□□■ ■□□□■ ■□□□□ ■□□□□ □□□□■ ■□□□■ ■□□□■ | |
■□□□■ □□□□■ □□□□■ □□□□■ ■□□□■ ■□□□□ ■□□□□ □□□□■ ■□□□■ ■□□□■ | |
□□□□□ □□□□□ □■■■□ □■■■□ □■■■□ □■■■□ □■■■□ □□□□□ □■■■□ □■■■□ | |
■□□□■ □□□□■ ■□□□□ □□□□■ □□□□■ □□□□■ ■□□□■ □□□□■ ■□□□■ □□□□■ | |
■□□□■ □□□□■ ■□□□□ □□□□■ □□□□■ □□□□■ ■□□□■ □□□□■ ■□□□■ □□□□■ | |
□■■■□ □□□□□ □■■■□ □■■■□ □□□□□ □■■■□ □■■■□ □□□□□ □■■■□ □■■■□ | |
*/ | |
// 提出コード (403 Byte) | |
y="■",n="□",a=n+y+y+y+n,b=y+n+n+n+y,c=n+n+n+n+n,d=n+n+n+n+y,e=y+n+n+n+n,x="\n" | |
console.log([a+x+b+x+b+x+c+x+b+x+b+x+a,c+x+d+x+d+x+c+x+d+x+d+x+c,a+x+d+x+d+x+a+x+e+x+e+x+a,a+x+d+x+d+x+a+x+d+x+d+x+a,c+x+b+x+b+x+a+x+d+x+d+x+c,a+x+e+x+e+x+a+x+d+x+d+x+a,a+x+e+x+e+x+a+x+b+x+b+x+a,a+x+d+x+d+x+c+x+d+x+d+x+c,a+x+b+x+b+x+a+x+b+x+b+x+a,a+x+b+x+b+x+a+x+d+x+d+x+a][+require("fs").readFileSync("/dev/stdin")]) | |
// あとで考えた最短コード (251 Byte) | |
x="\n",y="■",n="□",z=n+n+n,a=n+y+y+y+n+x,b=y+z+y+x,c=n+n+z+x,d=n+z+y+x,e=y+n+z+x,f=a+b+b,g=a+d+d,h=d+d+c,i=a+e+e,process.stdout.write([f+c+b+b+a,c+h+h,g+i+a,g+g+a,c+b+b+g+c,i+g+a,i+f+a,g+c+h,f+f+a,f+g+a][+require("fs").readFileSync("/dev/stdin")]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment