Randomize an array using constraints such that no number in the array repeats more than twice

Write a program to generate a 10-digit decimal number using constraint such that no
repetition of digits of more than 2(so 33 is allowed 333… is not) and no sequence of more than
3(234 is allowed but 2345 is not

i am unable to get this please help