Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
Created September 26, 2020 13:28
Show Gist options
  • Select an option

  • Save matthewmorrone/0abe551e20b2fedf63a2b6279d53cb08 to your computer and use it in GitHub Desktop.

Select an option

Save matthewmorrone/0abe551e20b2fedf63a2b6279d53cb08 to your computer and use it in GitHub Desktop.
static Integer[] performLottery(int numNumbers, int numbersToPick) {
List<Integer> numbers = new ArrayList<>();
for(int i = 0; i < numNumbers; i++) numbers.add(i + 1);
Collections.shuffle(numbers);
return numbers.subList(0, numbersToPick).toArray(new Integer[numbersToPick]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment