jjacquay712 Posted October 4, 2009 Share Posted October 4, 2009 Today I was bored and made a word search solver. I felt really proud of myself, but none of my friends are online to share it with . So I thought you guys might like it. Here is the link: http://johnjacquay.com/sandbox/crossword/ Here is a sample for you to input: U E I H U U A W G Z C W S R E Q R W K Q X Y E W X Y L I R K Y D S J B B J J J N H C E N D Y N C U C F V I P J P V Z U U Y U E O A P A M G G C F J I D P H P T E S F O C R V T X T V G V R V C O E I C O V N Y U S M F R A R V A Q N O O G S H L D R A U U V R O Y I K L W X F X E M F P A T X A R R W E D M X A L T T W N C L Y U U D S W J K F E U S C E F N A T Q C T T S J X D E Q N H E T E I A F W P U R T K P H P F R E A K S E G V Y L Z J K X K Z F A R M Words: COOLEST FORUM FREAKS PHP PHPFREAKS Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/ Share on other sites More sharing options...
mikesta707 Posted October 4, 2009 Share Posted October 4, 2009 pretty cool, but its case sensitive. You should either convert everything to capital letters, or lower case letters. I broke it by changing FREAKS to FREAkS Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930334 Share on other sites More sharing options...
jjacquay712 Posted October 4, 2009 Author Share Posted October 4, 2009 Yeah, I forgot about that, Ill change it real quick. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930336 Share on other sites More sharing options...
thebadbad Posted October 4, 2009 Share Posted October 4, 2009 Wrong forum. Where's the fun if you don't show us the source code? Also, when I enter test estt and searches for te, the vertical match isn't found. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930339 Share on other sites More sharing options...
jjacquay712 Posted October 5, 2009 Author Share Posted October 5, 2009 Wrong forum. Where's the fun if you don't show us the source code? Also, when I enter test estt and searches for te, the vertical match isn't found. That's strange, I just tested your example and it worked. Also, here is the source: <?php if ( $_POST['puzzle'] && $_POST['words'] ) { $words = explode("\n", str_replace(" ", "", trim($_POST['words']))); $letter_rows = explode("\n", str_replace(" ", "", trim($_POST['puzzle']))); $letters = array(); foreach ( $words as $word_index => $word ) { $words[$word_index] = strtolower(trim($word)); } $row_index = 0; foreach ( $letter_rows as $letter_row ) { $letter_row = strtolower(trim($letter_row)); for ( $n = 0; $n < strlen($letter_row); $n++ ) { $letters[$row_index][] = substr($letter_row, $n, 1); } $row_index++; } $width = count($letters[0]); $height = count($letters); $highlight = array(); $temphighlight = array(); $newletters = array(); $angles = array( 0 => array( 'x' => -1, 'y' => -1 ), 1 => array( 'x' => 0, 'y' => -1 ), 2 => array( 'x' => 1, 'y' => -1 ), 3 => array( 'x' => -1, 'y' => 0 ), 4 => array( 'x' => 1, 'y' => 0 ), 5 => array( 'x' => -1, 'y' => 1 ), 6 => array( 'x' => 0, 'y' => 1 ), 7 => array( 'x' => 1, 'y' => 1 ) ); foreach ( $letters as $row_index => $letter_row ) { foreach ( $letter_row as $letter_index => $letter ) { $newletters[$row_index][$letter_index] = '>' . $letters[$row_index][$letter_index]; foreach ( $words as $word_index => $word ) { foreach ( $angles as $index_add_index => $index_add ) { $found_index = 0; $temphighlight = array(); for ( $n = 0; $n < strlen($word); $n++ ) { if ( substr($word, $n, 1) == $letters[($index_add['y'] * $n) + $row_index][($index_add['x'] * $n) + $letter_index] ) { $found_index++; $temphighlight[$n]['y'] = ($index_add['y'] * $n) + $row_index; $temphighlight[$n]['x'] = ($index_add['x'] * $n) + $letter_index; if ( strlen($word) == $found_index ) { //echo 'Word "' . $word . '" Found At Angle ' . $index_add_index . "<br />"; $highlight[] = $temphighlight; break 1; } } else { break 1; } } } } } } foreach ( $highlight as $word ) { foreach ( $word as $coord ) { $newletters[$coord['y']][$coord['x']] = ' style="background-color: red;">' . $letters[$coord['y']][$coord['x']]; } } echo '<table>'; foreach ( $newletters as $row ) { echo '<tr>'; foreach ( $row as $letter ) { echo '<td'; echo $letter; echo '</td>'; } echo '</tr>'; } echo '</table>'; } ?> Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930346 Share on other sites More sharing options...
Jnerocorp Posted October 5, 2009 Share Posted October 5, 2009 to bad it doesnt find diagnol words Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930349 Share on other sites More sharing options...
jjacquay712 Posted October 5, 2009 Author Share Posted October 5, 2009 to bad it doesnt find diagnol words Yes it does... try this: abc def ghi aei Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930351 Share on other sites More sharing options...
PugJr Posted October 5, 2009 Share Posted October 5, 2009 Pretty cool. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930428 Share on other sites More sharing options...
darkfreaks Posted October 5, 2009 Share Posted October 5, 2009 XSSME: Failures:0 Warnings:154 Passes:0 Solution: strip_tags() Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930891 Share on other sites More sharing options...
448191 Posted October 5, 2009 Share Posted October 5, 2009 Give it a rest, he made something out of boredom, I imagine he cares less about XssMe warnings. Maybe find a different hobby? -- gotta be something you like to other than running Firefox plugins against random sites and colouring text. Wait, colouring, now there's an idea! I'm sure you can put that talent to better use. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-930911 Share on other sites More sharing options...
kaliza Posted October 13, 2009 Share Posted October 13, 2009 Give it a rest, he made something out of boredom, I imagine he cares less about XssMe warnings. Maybe find a different hobby? -- gotta be something you like to other than running Firefox plugins against random sites and colouring text. Wait, colouring, now there's an idea! I'm sure you can put that talent to better use. lol. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-936207 Share on other sites More sharing options...
Stephen Posted October 18, 2009 Share Posted October 18, 2009 The word search solver is awesome - I suck at word searches, and one of my teachers actually grades them ;-;. Thanks. Give it a rest, he made something out of boredom, I imagine he cares less about XssMe warnings. Maybe find a different hobby? -- gotta be something you like to other than running Firefox plugins against random sites and colouring text. Wait, colouring, now there's an idea! I'm sure you can put that talent to better use. Ooh, rage. Link to comment https://forums.phpfreaks.com/topic/176490-check-out-my-word-search-solver/#findComment-938995 Share on other sites More sharing options...
Recommended Posts