Skip to content

Commit

Permalink
Support for 5x5 and 6x6 boards
Browse files Browse the repository at this point in the history
  • Loading branch information
mwatson committed Sep 7, 2015
1 parent b35aacf commit 7388a84
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/example03.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
header('Content-Type: text/plain; charset=utf-8');

// if you just use composer:
//include(__DIR__ . '/../vendor/autoload.php');

// if you don't have an autoloader for some reason
include(__DIR__ . '/../src/BoggleTile.php');
include(__DIR__ . '/../src/BoggleException.php');
include(__DIR__ . '/../src/BoggleSolver.php');

// testing a board with a Qu tile
$boggleBoard = "N D O P N T E O O N A Z L N E A D M T S Y A E R L";

$boggle = new \BoggleSolver\BoggleSolver();

try {
$boggle->loadBoard($boggleBoard);
} catch (\BoggleSolver\BoggleException $e) {
die("exiting on error: " . $e->getMessage());
}

$words = $boggle->findWords();

echo "Boggle Board:\n\n";
echo $boggle->displayBoard();

echo "\n";

foreach ($words as $word => $paths) {
echo $word . "\n";
}

echo "\n";
6 changes: 6 additions & 0 deletions src/BoggleSolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public function loadBoard($board)
case 16:
$this->size = 4;
break;
case 25:
$this->size = 5;
break;
case 36:
$this->size = 6;
break;
default:
throw new BoggleException("Unknown board size of " . strlen($board));
}
Expand Down

0 comments on commit 7388a84

Please sign in to comment.