print grep { /(\d).*\1/ and eval "2 == tr/$1//" } map {sprintf "%04d",$_} (0..9999)