Skip to content

Commit 7388a84

Browse files
committed
Support for 5x5 and 6x6 boards
1 parent b35aacf commit 7388a84

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

examples/example03.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
header('Content-Type: text/plain; charset=utf-8');
3+
4+
// if you just use composer:
5+
//include(__DIR__ . '/../vendor/autoload.php');
6+
7+
// if you don't have an autoloader for some reason
8+
include(__DIR__ . '/../src/BoggleTile.php');
9+
include(__DIR__ . '/../src/BoggleException.php');
10+
include(__DIR__ . '/../src/BoggleSolver.php');
11+
12+
// testing a board with a Qu tile
13+
$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";
14+
15+
$boggle = new \BoggleSolver\BoggleSolver();
16+
17+
try {
18+
$boggle->loadBoard($boggleBoard);
19+
} catch (\BoggleSolver\BoggleException $e) {
20+
die("exiting on error: " . $e->getMessage());
21+
}
22+
23+
$words = $boggle->findWords();
24+
25+
echo "Boggle Board:\n\n";
26+
echo $boggle->displayBoard();
27+
28+
echo "\n";
29+
30+
foreach ($words as $word => $paths) {
31+
echo $word . "\n";
32+
}
33+
34+
echo "\n";

src/BoggleSolver.php

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ public function loadBoard($board)
108108
case 16:
109109
$this->size = 4;
110110
break;
111+
case 25:
112+
$this->size = 5;
113+
break;
114+
case 36:
115+
$this->size = 6;
116+
break;
111117
default:
112118
throw new BoggleException("Unknown board size of " . strlen($board));
113119
}

0 commit comments

Comments
 (0)