Sorry, but you don't make it clear whether the lottery agency might obtain the number 9969 or 4444, etc? Does the agency always obtain unique digits? You also aren't making it clear whether in the words:"Exactly one of the digits appears twice (e.g., 1223 or 9095)"
1. you are talking about the four digits which THE LOTTERY AGENCY obtains, or 2. you are talking about the number that YOU select to enter. Edwin