I think I've solved it: I've tested it on a few grids and they all work fine. It uses a proven method that has no reason *not* to work here.
I can't figure out why it's not flooding correctly.
Do I have to print the answer too, or do I leave it in memory?
Deluge
-
- Posts: 144
- Joined: Fri Mar 28, 2008 11:29 pm
- Location: #hacker.org on Freenode
I'm also having a problem with this one. I tested a few examples, including the example of the page, and some special cases, but I can't get my answer accepted. first I thought that it was a problem that for some reason the spaces were stripped, but even changing those to another value wouldn't help.
-
- Posts: 44
- Joined: Mon Feb 16, 2009 4:11 pm
- Location: UK
Uhm... I'm a bit confused about what this challenge is asking. So far I've got a program that correctly floods a few simple images, including the one from the page, but it still says that it doesn't flood correctly.
I might add that I based my program on the assumption that the top left pixel will only ever be 0 or 1. If it is 0 then the program floods correctly (as far as I can tell) and if it is 1 there is nothing to flood.
This assumption is based on the following two sentences from the description: Off pixels (the white ones in the sample image above) are zeroes. When your program terminates, all flooded pixels should have a value of 1.
Can anyone tell me if this is in fact correct?
I might add that I based my program on the assumption that the top left pixel will only ever be 0 or 1. If it is 0 then the program floods correctly (as far as I can tell) and if it is 1 there is nothing to flood.
This assumption is based on the following two sentences from the description: Off pixels (the white ones in the sample image above) are zeroes. When your program terminates, all flooded pixels should have a value of 1.
Can anyone tell me if this is in fact correct?
I think your assumptions are correct. I seem to remember it just says you failed to flood correctly even if the actual problem was an error, e.g. exceeding the cycle count. So if your algorithm does work on test images, but not when submitted, it's likely that it's just taking too many cycles, and you need to optimise it.
Hmm, this thread is old but for me the stated problem is still relevant.
My Program works fine on some sample inputs, including the one shown on the challenge-page and an empty grid. I'm always below 50k cycles, but the Program is not accepted (not flooding correctly).
Is there a limitation to the stack or call stack size? They are growing "quite big" (still < 1000) during the run.
I noticed some of those who had trouble with this as well finally solved this. So at least they should have an idea of what could be wrong with my program.
Any Hints?
thx
guga
My Program works fine on some sample inputs, including the one shown on the challenge-page and an empty grid. I'm always below 50k cycles, but the Program is not accepted (not flooding correctly).
Is there a limitation to the stack or call stack size? They are growing "quite big" (still < 1000) during the run.
I noticed some of those who had trouble with this as well finally solved this. So at least they should have an idea of what could be wrong with my program.
Any Hints?
thx
guga
When tested on HVM, have you checked the result of the algorithm. Are there just ones and zeroes and are they where they should be? Write it on a square paper to check it....guga wrote:Hmm, this thread is old but for me the stated problem is still relevant.
My Program works fine on some sample inputs, including the one shown on the challenge-page and an empty grid. I'm always below 50k cycles, but the Program is not accepted (not flooding correctly).
Is there a limitation to the stack or call stack size? They are growing "quite big" (still < 1000) during the run.
I noticed some of those who had trouble with this as well finally solved this. So at least they should have an idea of what could be wrong with my program.
Any Hints?
thx
guga
Hmm, it would help to make local copy of hvm and make some changes to show resulting memory (and increasy cycle count if needed), or experiment with python implementation.