Skip to content

Instantly share code, notes, and snippets.

@sgallese
Created December 2, 2009 23:42
Show Gist options
  • Save sgallese/247736 to your computer and use it in GitHub Desktop.
Save sgallese/247736 to your computer and use it in GitHub Desktop.
void setup(){
int counter = 0;
int beacon = 0;
for (int i = 0; i <= 55552222; i++){
//System.out.println("Using #: "+beacon);
int tempBeacon = beacon;
int currentDigit = 0;
boolean continueLoop = true;
while (continueLoop) {
int digit = tempBeacon % 10;
if (currentDigit < 4 && digit < 3){
//System.out.println("digit 1-4 and value 0-2");
}
else if (currentDigit >= 4 && digit < 6){
//System.out.println("digit 5-8 and value 0-5");
}
else{
//System.out.println("Digit or value not accepted, throw #");
continueLoop = false;
}
currentDigit += 1;
tempBeacon /= 10;
if (tempBeacon <= 0){
//System.out.println("We found a match!");
counter += 1;
continueLoop = false;
}
}
beacon += 1;
}
System.out.println("# of matches found: "+ counter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment