(Untitled)

May 10, 2010 11:21

SO. I entirely forgot, until 9:30 this morning, that I had a dentist's appointment at 10:30! But that's over now, and I'm home again. Sooo... breakfast, then code until 2, then work until 5, then more code. x_x

It wouldn't be so... daunting... if I just had any clue about what kind of algorithm to use. Or if I had more than friggin' 10 registers ( Read more... )

Leave a comment

Comments 4

serynth May 10 2010, 17:14:10 UTC
Hm. Do you have access to memory for storage? I mean, doing load/save sucks, but at least you get somewhere to put your extra stuff when you're not working with it.

As for why it had to be assembly: Your professor hates you :D

Reply

chaossaiyan May 10 2010, 22:03:08 UTC
Yes, we do have access to memory, I'm just...

I know all the syntax, how to code it, etc. It's how to solve it that's mostly bugging me.

It's a Tents puzzle and we're given the size of the grid, how many tents and how many per row/coulmn, and where the trees are, and we have to make the programsolve the puzzle. It's the algorithm to do so that's got me so confused, mostly, and partly how to implement it in Assembly x_x;

Reply

serynth May 10 2010, 22:46:51 UTC
Hmm, so, does it have to be a smart algorithm? I mean, you could take the per-tree naive path for O(4^n), assuming that each tree has exactly one tent next to it and the number of tents equals the number of trees. It's not going to set any speed records, but it'll get the job done. Are you graded on efficiency or just correctness?

EDIT: Hmm, the first condition isn't necessary. I tried one of the later puzzles.

EDIT2: Yep, seems like my guess was correct. In pseudocode, naively:

Given a tree and the partial map:
If the tree is the null tree:
Return #tents/row = #tents/row and #tents/col = #tents/col
Else:
For direction in north/south/east/west:
If that square is empty and has no adjacent tent:
Place tent in square.
Recurse with next tree in list.
If returned OK:
Return OK.
Else:
Remove tent from square.
Return not OK.

EDIT3: Whoops, formatting error!

Reply

chaossaiyan May 10 2010, 23:49:06 UTC
. . . Th...thank you o_o;; That's an amazing help...

Reply


Leave a comment

Up