Created
March 28, 2022 20:01
-
-
Save Deleplace/bf46d97a197bda2fde11b559f3b0aa45 to your computer and use it in GitHub Desktop.
Pick uniformly a random integer in [a..b]
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
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