Created
June 3, 2012 08:45
-
-
Save fukayatsu/2862603 to your computer and use it in GitHub Desktop.
任意の桁数の答えをランダムに生成するアレ
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
/** | |
* 任意の桁数の答えをランダムに生成します | |
* | |
* @param size | |
* 答えの桁数(1~10) | |
* @return 答え | |
*/ | |
private List<Integer> generateAnswer(int size) { | |
assert (1 <= size && size <= 10); | |
Integer[] nums = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
List<Integer> numbers = Arrays.asList(nums); | |
Collections.shuffle(numbers); | |
return numbers.subList(0, size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment