#include <iostream>
#include <random>
#include <chrono>
// returns a pseudo-random number in [001,505).
// changes the random number every 24 hours
int random_number()
{
usingnamespace std::chrono ;
// the time point at which the random number was generated
staticauto timestamp = steady_clock::now() ;
// the random engine and distribution
static std::mt19937 twister( timestamp.time_since_epoch().count() ) ;
static std::uniform_int_distribution<int> distribution(1,504) ;
staticint random = distribution(twister) ; // initial value
auto time_now = steady_clock::now() ; // current time
// if 24 hors have passed since the last random number was generated
if( duration_cast<hours>( time_now - timestamp ) > hours(24) )
{
timestamp = time_now ; // update the timestamp
random = distribution(twister) ; // ang generate a new random number
}
return random ;
}