Background
I was working on a system where for convenience (not security) people could use four digit codes to identify themselves. I figured this is something that may actually be useful in many real cases, yet is well enough defined that it could make a nice challenge!
Explanation of pin codes and typo resistant sets
EDIT: Based on the comments, this is probably a more formal definition:
I think a mathematical way of specifying what you are looking for is a maximal set of strings with length 4 over the alphabet {0,1,2,3,4,5,6,7,8,9} with minimum pairwise hamming distance 2, if it helps others.
There are 10000 possible pin codes (0000-9999).
Example pin code
1234
However, since a typo is easily made you are to generate a set of pincodes that is resistant to a single typo.
Example of set that is NOT resistant to single typo:
0000
0005 (if you mistype the last digit as 0 instead of 5, you get another code in the set)
Example of set that IS resistant to single typo
0000
0011
0101
0202
Allowed outputs
The allowed output can be a bit flexible, specifically:
- A pincode may be a string or a number
- You may always have separators (e.g. comma, newline), however if your codes are always represented as 4 digits separators are optional
- The codes should be represented by 0-9, not other characters
Example sets:
0011,0022: OK
00220011: OK
11,22,33: OK
112233: NOT OK
abcd,abef: NOT OK
{'1111',/n'2222'}: OK
Scoring system
The primary score is the number of unique pin codes generated (note that 0001,1000 would count as 2).
Edit: If your code does not always generate the same amount of unique pin codes you must estimate the amount it will at least generate in 95% of the cases and you may use that as your score. So for example if you uniformly randomly generate between 300 and 400 unique pincodes, your score would be 395.
In case there is a tie, the shortest code wins!
Please post your score as: Language, #Unique codes generated with bytes (e.g. Python, 30 codes generated with 123 bytes)
(I guess formally this could be rewritten to 'generate X typo resistant pin codes' but as I have no idea what X is I will keep it like this, this also allows simpler solutions to compete against each other on lenght for 'third place' and beyond.)
In principle no inputs are needed and for simplicity sake I will not make it part of the challenge and scoring, but it would be interesting to see how the code would need to be changed to allow for various length pin codes.
{0,1,2,3,4,5,6,7,8,9}
with minimum pairwise hamming distance 2, if it helps others. \$\endgroup\$