Created
January 6, 2017 12:07
-
-
Save Grassboy/83a904ba0af7e92da0d203d3822a8cce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var valid_list = []; | |
var diffCount = function(a, b) { | |
var result = 0; | |
if(parseInt(a/100000)%10 != parseInt(b/100000)%10) result++; | |
if(parseInt(a/10000)%10 != parseInt(b/10000)%10) result++; | |
if(parseInt(a/1000)%10 != parseInt(b/1000)%10) result++; | |
if(parseInt(a/100)%10 != parseInt(b/100)%10) result++; | |
if(parseInt(a/10)%10 != parseInt(b/10)%10) result++; | |
if(parseInt(a/1)%10 != parseInt(b/1)%10) result++; | |
return result; | |
}; | |
for(var i = 0; i < 1000000; i++) { | |
var valid = true; | |
for(var j = 0; j < valid_list.length; j++){ | |
if(diffCount(valid_list[j], i)<2) { | |
valid = false; | |
break; | |
} | |
} | |
if(valid) { | |
valid_list.push(i); | |
} | |
} | |
alert(valid_list.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment