Cows and bulls to allow duplicates
If you are allowing 5 digits then you can have two different kinds of repetitions. That is, you could have a code like 11122, so this should probably be represented somehow such that the ”milk” is different from the 11111 case. 

Since you can have at most two repetition groups, it seems like the easiest thing to do would be to have another variable, (cans of milk vs buckets of milk?) for the second repetition group, if any. 

Another thing to consider is what values of the milk variable should indicate which amount of repetitions. 1 milk for 1 repetition, (11234 for example,) and two milks for two, (11123) makes sense from a certain point of view, but having two milks mean two values are the same, (11234) three for three values that are the same, (11123) and the milk being ignored otherwise might be more intuitive.