Last active
October 31, 2016 16:32
-
-
Save gecko655/bc02faaae92cad4bc7f460e603dbd308 to your computer and use it in GitHub Desktop.
29reachに投げ捨てたコードたち
This file contains hidden or 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~100までの整数においてFizzBuzzプログラムを実装してください。 | |
好きな言語で、可能な限り可読性が高く、可能な限り簡潔なコードで記述してください。 | |
*/ | |
//Java 8 | |
import java.util.stream.*; | |
public class FB { | |
public static void main(String[] args) { | |
IntStream.rangeClosed(1, 100) | |
.mapToObj(i->i%15==0?"Fizz Buzz": | |
i%3==0?"Fizz": | |
i%5==0?"Buzz": | |
i) | |
.forEach(System.out::println); | |
} | |
} |
This file contains hidden or 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
/* | |
ニクリーチにちなんで「2」と「9」を使ったユニークな関数を実装してください。 | |
言語は自由とし、必要であれば関数の意図をコメント形式で記述してください。 | |
*/ | |
class Niku{public static void main(String[]x){for(int j=2,i;j-->0;)for(i=5;++i<48;System.out.print(i%6>4?10:(1<<(i%6+2)/3&"坕嵝".charAt(j)>>i/6*3/5*3)>0?'□':'■'));}} | |
/* | |
Input: | |
なし | |
Output: | |
□■■■□ | |
□□□□■ | |
□□□□■ | |
□■■■□ | |
■□□□□ | |
■□□□□ | |
□■■■□ | |
□■■■□ | |
■□□□■ | |
■□□□■ | |
□■■■□ | |
□□□□■ | |
□□□□■ | |
□■■■□ | |
7セグメントの点灯&消灯の情報は15bitで表現できるため、 | |
1つの7セグメントの数字を1つのJavaの16bit文字列で表しています。 | |
すなわち、'嵝'=0b0_101_110_101_011_101=2、坕=0b0_101_011_101_010_101=9です。 | |
詳しくは、食事をしながらお話ししましょう。 | |
元ネタ:http://bit.ly/1Fc3eX3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment