#include <iostream>
#include <string>
#include <algorithm>
#include <random> // for std::mt19937 and std::random_device
// Function to shuffle digits and return 3 random digits
std::string getRandomThreeDigits(int num) {
std::string s = std::to_string(num);
// Ensure it's exactly 6 digits
if (s.size() != 6) {
return "Error: number must be 6 digits";
}
// Create a random engine (seeded with nondeterministic source)
static std::random_device rd;
static std::mt19937 gen(rd());
std::shuffle(s.begin(), s.end(), gen); // Shuffle digits
return s.substr(0, 3); // Take first 3 after shuffle
}
int main() {
int num = 123456; // Example 6-digit number
std::string randomThree = getRandomThreeDigits(num);
std::cout << "Random three digits: " << randomThree << std::endl;
}
/*
run:
Random three digits: 416
*/