Skip to content

Instantly share code, notes, and snippets.

@lyrieek

lyrieek/java Secret

Last active February 9, 2021 06:09
Show Gist options
  • Save lyrieek/61b435d26c10aba82b17d65f180199ab to your computer and use it in GitHub Desktop.
Save lyrieek/61b435d26c10aba82b17d65f180199ab to your computer and use it in GitHub Desktop.
2021 java
final int seed = 0xffff;
final int round = seed >> 1;
for (int i = seed; i > 0; i--) {
Random foo = new Random(seed);
Random bar = new Random(seed);
int reverse = 0;
int temp = i;
while(temp != 0) {
reverse = reverse * 10 + (temp % 10);
temp /= 10;
}
if (i == reverse || i % 10 == 0 || reverse > seed) {
continue;
}
IntStream.range(0, i).forEach(e -> foo.nextInt());
IntStream.range(0, reverse).forEach(e -> bar.nextInt());
int res = foo.nextInt(round);
if (res == bar.nextInt(round)) {
System.out.println(res);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment