Created
December 4, 2015 21:45
-
-
Save ninnypants/4d98406808bd234776f4 to your computer and use it in GitHub Desktop.
Solves Advent of code puzzle 4 though brute force. May output the solution to the first challenge multiple times.
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
<?php | |
$match5 = 0; | |
$match6 = 0; | |
$i = 0; | |
$salt = 'yzbqklnj'; | |
while ( '000000' !== $match6 ) { | |
$i++; | |
$hash = md5( $salt . $i ); | |
$match5 = substr( $hash, 0, 5 ); | |
$match6 = substr( $hash, 0, 6 ); | |
if ( '00000' === $match5 ) { | |
echo 'answer 1: ' . $i . "\n"; | |
} | |
} | |
echo 'answer: ' . $i; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment