Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Uninitialized warnings trouble

by hv (Prior)
on Dec 13, 2022 at 23:18 UTC ( [id://11148846]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Uninitialized warnings trouble
in thread Uninitialized warnings trouble

Oh, I had a typo/thinko in my previous response - you were correctly counting from 0 to 98, but I wrongly suggested you should go up to $row[$counter][99] when I should have said 98. (So I think you should still be getting a few warnings.)

My output is: 1673

That's not what I get, but it isn't very far out. Maybe you could show the rest of the changes you made?

It would probably be more practical to start with a smaller grid, so that you can more easily see what the correct answer is - which would mean generalizing your code to discover the size when you read the input file, but that's a useful thing to do in any case. Then you could test your code against some simple cases, like:

222 222 (8 visible) 222 222 122 (9 visible) 222 222 221 (9 visible) 222 212 222 (9 visible) 222 222 222 (9 visible) 212 222 212 (8 visible) 222 22222 21112 (12 visible, test horizontal bounds) 22222 222 212 212 (12 visible, test vertical bounds) 212 222 etc.

Replies are listed 'Best First'.
Re^4: Uninitialized warnings trouble
by Anonymous Monk on Dec 14, 2022 at 04:53 UTC

    "99" did work. I think it did because I increment my counter before I start my if loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found