Last active
August 29, 2015 14:01
-
-
Save na2hiro/ef012daaf979a63cda9f to your computer and use it in GitHub Desktop.
JavaScript FizzBuzzダンジョン http://codezine.jp/article/detail/7546
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
// 20字(<=100字) | |
function yourCode() { | |
var arr = []; | |
for (var i = 1; i <= 100; i ++) { | |
arr.push([i, "fizz", "buzz", "fizzbuzz"][i%3?i%5?0:2:i%5?1:3]); | |
} | |
return arr; | |
} |
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
// 15字(<=30字) | |
// 禁止 ? : & | , $ eval function Function if switch for while return | |
function yourCode() { | |
var arr = []; | |
for (var i = 1; i <= 100; i ++) { | |
arr.push([i, "fizz", "buzz", "fizzbuzz"][!(i%3)+!(i%5)*2]); | |
} | |
return arr; | |
} |
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
// 25字(<=40字) | |
// 禁止 ? : & | , $ eval function Function if switch for while return ! ^ ~ < > = Math | |
function yourCode() { | |
var arr = []; | |
for (var i = 1; i <= 100; i ++) { | |
arr.push([i, "fizz", "buzz", "fizzbuzz"][3-"011"[i%3]-"02222"[i%5]]); | |
} | |
return arr; | |
} | |
// ==が禁止されてるとは思わなかった時のバージョン | |
// 19字(<=40字) | |
function yourCodeOld() { | |
var arr = []; | |
for (var i = 1; i <= 100; i ++) { | |
arr.push([i, "fizz", "buzz", "fizzbuzz"][(i%3==0)+(i%5==0)*2]); | |
} | |
return arr; | |
} |
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
// 33字(<=70字) | |
// 禁止 ? : & | , $ eval function Function if switch for while return ! ^ ~ < > = Math % | |
function yourCode() { | |
var arr = []; | |
for (var i = 1; i <= 100; i ++) { | |
arr.push([i, "fizz", "buzz", "fizzbuzz"][3-/\./.test(i/3)-/\./.test(i/5)*2]); | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment