Deluge

Post Reply
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Deluge

Post by therethinker »

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?
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

just leave it in memory.
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

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.
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post by m!nus »

don't be too happy with your solution for deluge, the challenges that come after it are a "bit" more difficult.

i tried searching some more optimal algorithm but didn't find real code where i can see how it gets implemented :/
Chocoholic
Posts: 44
Joined: Mon Feb 16, 2009 4:11 pm
Location: UK

Post by Chocoholic »

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?
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

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.
guga
Posts: 17
Joined: Fri Mar 02, 2012 2:39 pm

Post by guga »

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
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

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
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....

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.
Post Reply