Last active
December 2, 2018 16:59
-
-
Save mspreij/a4b5922c855152c9366eedb926e2252e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// having turned input into an array.. | |
// Levenshtein 0.04 seconds | |
for ($i=0; $i < 250; $i++) { | |
for ($j=$i+1; $j < 250; $j++) { | |
if (levenshtein($input[$i], $input[$j]) == 1) { | |
echo $input[$i].':'.$input[$j]."\n"; | |
} | |
} | |
} | |
// loops 0.4 seconds | |
for ($i=0; $i < 249; $i++) { | |
for ($j=$i+1; $j < 250; $j++) { | |
for ($c=0; $c < 26; $c++) { | |
if (substr($input[$i], 0, $c)==substr($input[$j], 0, $c) and substr($input[$i], $c+1)==substr($input[$j], $c+1)) { | |
echo $input[$i].' : '.$input[$j]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment