in reply to Re: Re: Depth First Search and Boggle
in thread Depth First Search and Boggle
The point is that all your parameters, including %visited get flattened and passed as a single list:
($x, $y, key1,val1,key2,val2,...,$word)
Inside dfs(), Perl has no way to tell that the last value ($word) is not an element of the list that must be assigned to %visited, so it attempts to assign that too. Hence the odd number of elements.
$word will never be assigned a value.
Swap the order of %visited and $word inside dfs() and when you call dfs() and your code will (probably) work!
|
|---|