I don't know, but at times I'm super smart when it comes to programming and puzzle solving. Here's my solution to one of the PI day challenges given every 14th day of March:
"I’m thinking of a ten-digit integer whose digits are all distinct. It happens that the number formed by the first n of them is divisible by n for each n from 1 to 10. What is my number?"
my code:
var usedNumberBits = [0,0,0,0,1,0,0,0,0];
console.log(optionOne(parseInt(0),parseInt(1),usedNumberBits));
function optionOne(num, place, usedNumberBits){
var success = false;
var offset = parseInt(0);
var x;
var curNum;
if(place%2==1){
offset = 1;
x=0;
}
else{
x=1;
}
x = parseInt(x);
num*=10;
if(place==5){
num+=5;
success=optionOne(num,place+1,usedNumberBits);
return success;
}
for(; x<=4; x++){
curNum = 2*x+offset;
if(usedNumberBits[curNum-1]!=1){
usedNumberBits[curNum-1]=1;
num+=curNum;
if(num%place==0){
if(place<9){
success = optionOne(num,place+1,usedNumberBits);
}
else{
success = true;
console.log(num*10);
}
}
usedNumberBits[curNum-1]=0;
if(success){
return success;
}
num-=curNum;
}
}
return success;
}