Numbers that are easy to remember yet theoretically not easily made
Your challenge is to make a program/function in any language that generates uniformly random numbers that fit these criteria:
Length is 5 digits
There are two separate repeated digit pairs
One set of repeated digits is at the beginning or end and the digits are next to each other
The odd number out is surrounded by the other pair of digits
The two digit pairs and the other number should all be unique
Your program may support numbers with leading zeroes or not, at your discretion. If leading zeroes are supported, they must be included in the output: 06088, not 6088. If leading zeroes are not supported, then numbers like 06088 should not be generated at all.
Test Cases
Accepted Outputs:
55373 55494 67611 61633 09033 99757 95944 22808 65622 22161
Not accepted outputs:
55555 77787 85855 12345 99233 12131 abcde 5033
More acceptable test cases can be found at this pastebin link.
These were made with this python program:
import random for i in range(100): if random.randint(0,100) >= 50: #Put pair touching at beginning if true temp = [] #working array temp.append(random.randint(0,9)) #append random digit temp.append(temp[0]) #append the same digit again x = random.randint(0,9) while x == temp[0]: x = random.randint(0,9) temp.append(x) #append another unique digit y = random.randint(0,9) while y == temp[0] or y == temp[2]: y = random.randint(0,9) temp.append(y) #append another unique digit, and the previous unique digit temp.append(x) else: #Put touching pair at end temp = [] #working array temp.append(random.randint(0,9)) #append random digit #While not unique, try again x = random.randint(0,9) while x == temp[0]: x = random.randint(0,9) temp.append(x) #append another unique digit temp.append(temp[0]) #append the same 0th digit again y = random.randint(0,9) while y == temp[0] or y == temp[1]: y = random.randint(0,9) temp.append(y) #append another unique digit twice temp.append(y) tempstr = "" for i in temp: tempstr += str(i) print tempstr
This is code-golf, so shortest answer in bytes wins!
random
does not mean uniformly so \$\endgroup\$