Generation of arrays that have certain repeat.

Hey

With me is a question that am requesting to be answered. Am interesting in making an addition of numbers between 1 and 10 by ensuring that each number is repeated twice in a random indexing. I already did a generation of arrays that had 20 indexes and my focus now is how I can add some values let us say like https://www.theengineeringprojects.com/2021/12/esp32-low-power-modes.html [ 1237645283936288634838367837338398398338].

How is this made possible?

Thanks.
Last edited on
To ensure that each number is repeated twice, add each number twice. For example: 228855772233998844

To get random indexing, after the numbers are added, shuffle the sequence randomly.
Use std::shuffle https://en.cppreference.com/w/cpp/algorithm/random_shuffle
Topic archived. No new replies allowed.