How can we customize the code with rand() function in order to generate a n-digit number, where n<8, without digit duplicates in it? Suppose I want to generate a 4 digit number from 1000 to 9999, this number should not contain digit duplicates: for instance 1023 4798, etc. Btw, we may not generalize n.
Edits
I skimmed through the answers in the question I was adressed to. I honestly think that the problem of generating a sequence of digits without a single duplicate in it is in my opinion easier that generating a number with no duplicate digits. Still looking for an answer.
My code is a real mess and truthfully does not contain a single try to tackle the stated problem. I have a paper draft but still it's based on assigning an integer variable to each digit in a number and a small loop which checks if some of them are equal and increment/decrements one of them. This sounds like a bad idea even to me, but this is all I can come to.