The same code does not generate random groups when run on my mac. On the playground it does. I am compiling with g++ and I am not getting errors about missing libraries.
It worries me because I use random algorithms for my work. Does anyone know why on my Mac random_shuffle gives always the same result despite setting srand? Sorry if it is trivial.
I insert the code (algorithm is unfinished) as context.
Sorry I am not Mac user but can you try running this code once and see the result.
I have used shuffle and not random_shuffle which is deprecated as ~ swim ~ said.
And if this code meets your requirement then we can assume it's due to random_shuffle.
Thank you! I will try the alternative shuffle.
I had read this stackoverflow post but also I am confused by different explanations to the same problem. One states that the ios time being a very large number causes overflow and the seed resulting in an identical number every time, so that srand(time(NULL)) should be avoided on IOS. Is that so?
RKK, I tried your code and it works on my mac. still, it is changing random_shuffle to shuffle as well as the random generator, srand to mt19937. so either could be the cause. i am curious to understand if the problem is random_shuffle or srand but the main thing is to have something working, thank you!
To make a real random value doesn't need to use a kind of "seed" or something like that?, I don't remember what lang have that method to generate a real random, that seed is use with the time function, someone can tell me what language is that?