in reply to Uninitialized warnings trouble
I am being flooded with uninitialized value warnings for lines 52 ...
Let's start with this one: your previous loop (which I visualize as "looking to the left") is working ok. In that case, you are testing visibility of $row[$current][$i], and looking at the tree $counter to the left of it as $counter ranges from 1 to $i. So you check from $row[$current][$i - 1] down to $row[$current][0].
In this loop (which I visualize as "looking to the right") you want to check each tree $counter to the right, so you should end up ranging from row[$current][$i + 1] to $row[$current][99] $row[$current][98]. But you are letting $counter run from 1 to $i again, so you actually check from row[$current][$i + 1] to $row[$current][$i + $i].
If you fix that error, it should then be obvious what you need to do to fix the remaining two loops, and I think it is possible you'll even get the correct answer.
When you do, I would love for you to come back with your finished code - I'd like to give you tips on how to improve the code, but I don't want to spoil the fun and learning experience of solving the problem first. :)
Update 2022-12-13 19:06: correct index from 99 to 98
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Uninitialized warnings trouble
by Anonymous Monk on Dec 13, 2022 at 21:42 UTC | |
by hv (Prior) on Dec 13, 2022 at 23:18 UTC | |
by Anonymous Monk on Dec 14, 2022 at 04:53 UTC |