Login | Register

RoboZZle Forums

Forums / Puzzles / arbitrary counting

Thread for puzzle arbitrary counting. Hints are OK, but please no full solutions.


Log in to comment.


jing, 15 months ago.

lovely. to turn at the 4th corner you need a cute trick.

babosae's comment after solving the puzzle, 54 months ago.

lovely. you need to use a trick

babosae's comment after solving the puzzle, 54 months ago.


babosae's comment after solving the puzzle, 54 months ago.

I always try to avoid puzzles with paint. But this is actually quite good. In fact my eyes missed the paint option at first :-) but chadg1980's comment got me back on track.

reinerbaumwoll, 66 months ago.

There is red everywhere! oops.

chadg1980's comment after solving the puzzle, 66 months ago.

Very good explanation sticky. Maybe it should be posted on wiki?

lucjansz, 107 months ago.

I'd hate to toot my own horn, but lcurtne hardly did any explaining.

sticky, 114 months ago.

Thanks icurtne, your explanation has helped me to really understand this kind of stacking, I was just guessing at it before. Great puzzle too, thanks.

Super_Flautist, 114 months ago.

Beginners heaven. Bravo!

arkangelsk1's comment after solving the puzzle, 119 months ago.

Oh, diabolical! My head hurts, but I think I've got it now, although it's going to take some practice. Thanks for the replies everyone, and special thanks to sticky for the puzzle/solution and lucid explanation.

lcurtne, 119 months ago.

Many puzzles of this format follow this sequence: push, pop, turn, repeat.

There's two general ways of doing this, which differ in the number of functions required, and the number of steps that are popped. A good illustration of the difference is in these two puzzles:


Since this puzzle only has 2 functions, I could only try the first method, and the extra instructions required were mostly just trying the simplest thing that might work.

keba, 119 months ago.

How easy or hard a puzzle is does not directly translate to how enjoyable it is. For this puzzle you could have made the path a bit longer and in a way that reduced the number of possible solution. For instance in your puzzle you can move then paint or paint then move. The two solutions will look different when solved. If you draw your puzzles carefully you can weed out the unintended solutions. This line of thinking eventually leads to hack blocking and will keep your puzzle as challenging as you intend them to be.

Sticky is very good with stacking puzzles. Listen and learn.

axorion, 119 months ago.

Hey, thanks, sticky. I really appreciate your taking the time to give me such a detailed explanation. I'll try to absorb it all tomorrow and be on my way to a more satisfying Robozzling experience. Thanks again...

lcurtne, 119 months ago.

In the second sentence above, I meant 'single function stacking involving multiple colors...'

sticky, 119 months ago.

Here's an example puzzle and solution that might help.

This has conveniently placed red tiles that indicate where turns should be placed on the stack in order to traverse the mini spiral on the right.
This is a multiple function stacking technique (single function stacking involving multiple puzzle tends to be more difficult and less intuitive for learning). So rather than having a stacking function there's a stacking set of functions F2, F3, F4 (the actual action of stacking only occurs in F3 and F4).
I first call F2 which moves forward once, then depending on the color of the resulting movement, calls either F3 if on blue, or F4 if on red. The first tile (colored green) doesn't affect the stack because the stacking functions aren't called while the robot is on this tile.
The robot first lands on a blue tile and calls F3. F3 then calls F2. But there is a forward command after the F2 command. This forward command isn't executed (according to the order of the commands, F2 must be executed first) and is put on the stack to be executed when F2 is finished.
So after landing on the first blue tile, F2 is called again. This means the robot moves forward, then calls either F3 or F4 depending on color. The second time, the robot lands on a red tile and calls F4. F4 then calls F2. This time, we put a left turn and a forward command after the F2 call. This way, we add a left turn to the stack.
F2 is called again and the process repeats. As long as the robot lands on a blue or red tile, it will add either a forward or a left turn to the stack. When it reaches a green tile, F2 doesn't have anything to call, and therefore cannot recursively call itself. Now the stack releases and the left turns and forward commands that we've saved finally execute.

sticky, 119 months ago.

My last sentence sums up that problem.
"These commands are only executed when F2 stops calling itself, then each copy on the stack executes starting with the most recent and ending with the first."
This means that after creating a stack of commands, the order in which the stack is executed begins with the command most recently put on the stack and going backward through the order in which the stack was created. The command that was put on the stack first will be executed last.
In order to solve puzzles in which the commands on the stack vary, you must put the proper commands on the stack in the right order. This will always depend on the shape of the puzzle as it is the puzzle that you use to develop the stack.
A good example is 'Easy Double Spiral' (http://robozzle.com/puzzle.aspx?id=881) which requires you to memorize the shape of a spiral. The second half of the puzzle requires you to traverse the spiral shape in the opposite direction as the first half. The turns are marked in the first half by red tiles. When stacking commands for the second half, you have to stack a forward command for each blue tile, and a left turn command (and a forward) for each red tile.
So when traversing the first half, each time you come across a blue tile, you must recursively call back your stacking function, but leave a forward command that does not execute to be executed when the stack releases. Likewise for red tiles, when you reach a red tile, you must call your stacking function, but leave a left turn behind.

sticky, 119 months ago.

So, did your solution contain a nested recursion? It seems like the problem I'm running up against is sometimes it seems like the 'extraneous' commands need to vary as you're unwinding the stack, and I don't see how to do that...

lcurtne, 119 months ago.

I solved this quickly because it requires only basic knowledge of a simple stacking process, of which I am familiar. I didn't count individual tiles to see if the process would work, I assumed that it was possible to solve using the process I identified as appropriate to the puzzle and I tried it.

Stacking occurs whenever you call a function with some recursive function call inside of it referencing itself, say F2, with some commands following the recursive call of F2. Each time F2 calls itself, it leaves a copy of these extraneous commands on the stack. These commands are only executed when F2 stops calling itself, then each copy on the stack executes starting with the most recent and ending with the first.

sticky, 119 months ago.

Question for those that solved this: Apparently it was pretty easy for you to solve. Was it because you know how to 'count' the stuff on the stack, or was there some reductive solution? I made up this puzzle by creating the solution first, then tailoring the puzzle to fit the solution. I've been struggling with this counting thing for days (Learning Stack, Stack Memory Tutorial, etc.) and I still couldn't solve my own puzzle. It almost seems like there's something about the 'API' that I don't know about or understand, and the 'tutorials' all seem to require solving the puzzle without any narrative or explanation. Poor me. Anyway, I'll keep trying but I sure could use some broad hints. P.S., I'm not unfamiliar with recursive functions, which I frequently use on my job as a .NET developer, but I'm starting to acquire somewhat of a self-image problem. Maybe you could help me out? ...and, thanks, of course...

lcurtne, 119 months ago.

Previous page (1 / 1) Next page

©2009 Igor Ostrovsky and other contributors. Terms of use