Skip to content

Latest commit

 

History

History
13 lines (9 loc) · 375 Bytes

random.md

File metadata and controls

13 lines (9 loc) · 375 Bytes

Randomness utilities

Code

minstd_rand rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) { return uniform_int_distribution<T>(a, b)(rng); }
template <typename T> typename vector<T>::const_reference choice(const vector<T>& xs) { return xs[randint(0, (int)xs.size()-1)]; }

Problems

Sources