æè¿ãTwitterã®ã¿ã¤ã ã©ã¤ã³ä¸ã§FizzBuzzã大æµè¡ï¼
FizzBuzzã¨è¨ãã°ãããã°ã©ãã³ã°åç´è
ã®ããã®ç·´ç¿ç¨ã®ã¯ã¤ãºã§ãã
1ããæ°ãã¦è¡ãã3ã®åæ°ã®ã¨ãã«ã¯"Fizz"ã5ã®åæ°ã®ã¨ãã«ã¯"Buzz"ã3ã®åæ°ãã¤5ã®åæ°ã®ã¨ãã¯"FizzBuzz"ã¨æ°åã®ä»£ããã«è¡¨ç¤ºããã¨ããç°¡åãªããã°ã©ã ã§ãã
ãã£ãããªã®ã§æµè¡ã«ä¹ã£ã¦ãFizzBuzzãæ¸ãã¦ã¿ã¾ããã
ãã®ãããªç°¡åãªããã°ã©ã ã§ããæ¸ãæ¹ã«åæ§ã表ããã®ãããã°ã©ãã³ã°ã®é¢ç½ãã¨ããã§ããâª
Javaã«ããå®è£
public class FizzBuzz { public static void main(String[] args) { for(int i = 0; i < 100; i++) { final int number = (i + 1); final boolean fizz = (number % 3 == 0); final boolean buzz = (number % 5 == 0); if(fizz) { System.out.print("Fizz"); } if(buzz) { System.out.println("Buzz"); } else { if(fizz) { System.out.println(); } else { System.out.println(number); } } } } }
Groovyã«ããã¯ã³ã©ã¤ãã¼
for(i in 1..100)println(((a=i%3)?"":"Fizz")+(i%5?(a?i:""):"Buzz"))
Dartã«ããã¯ã³ã©ã¤ãã¼
main(){var n;for(int i= 0;i<100;print(n+(i%5?(n?"":i):"Buzz")))n=(++i%3)?"":"Fizz";}
Dartã¯ã¤ãå
æ¥Googleããçºè¡¨ãããæ°ããè¨èªã§ãã
詳細ã¯Dart: Structured web apps
工夫ãããã«ã¼ã«ãå¶éãããããã¨é¢ç½ã
ä¸è¨ã®ããã«ã¯ã³ã©ã¤ãã¼ã§ãã£ãããã§ããã ãçãã³ã¼ãã§æ¸ãä¸ããã¨ããã®ãé¢ç½ãã§ãã
ã¾ãã%ï¼å°ä½æ¼ç®åï¼ã使ããªãã§è§£ããã¨ãã£ãã«ã¼ã«ã®å¶éãçãã¾ããï¼
ãã²ã¿ãªããããã£ã³ã¬ã¸ãã¦ã¿ã¦ãã ãã(ï¼¾â½ï¼¾)/