Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created June 3, 2012 08:45
Show Gist options
  • Save fukayatsu/2862603 to your computer and use it in GitHub Desktop.
Save fukayatsu/2862603 to your computer and use it in GitHub Desktop.
任意の桁数の答えをランダムに生成するアレ
/**
* 任意の桁数の答えをランダムに生成します
*
* @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