Skip to content

Instantly share code, notes, and snippets.

@Deleplace
Created March 28, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deleplace/bf46d97a197bda2fde11b559f3b0aa45 to your computer and use it in GitHub Desktop.
Save Deleplace/bf46d97a197bda2fde11b559f3b0aa45 to your computer and use it in GitHub Desktop.
Pick uniformly a random integer in [a..b]
import 'dart:math';
void main() {
print(pick(2, 10));
}
int pick(int a, int b) => a + new Random().nextInt(b - a + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment