• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 16:54
CET 22:54
KST 06:54
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT28Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (Feb 16-22): MaxPax doubles0Weekly Cups (Feb 9-15): herO doubles up2ACS replaced by "ASL Season Open" - Starts 21/0244LiuLi Cup: 2025 Grand Finals (Feb 10-16)46Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2
StarCraft 2
General
ByuL: The Forgotten Master of ZvT How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Oliveira Would Have Returned If EWC Continued Behind the Blue - Team Liquid History Book Weekly Cups (Feb 16-22): MaxPax doubles
Tourneys
The Dave Testa Open #11 Sparkling Tuna Cup - Weekly Open Tournament PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) StarCraft Evolution League (SC Evo Biweekly) Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
Mutation # 514 Ulnar New Year The PondCast: SC2 News & Results Mutation # 513 Attrition Warfare Mutation # 512 Overclocked
Brood War
General
Soma Explains: JD's Unrelenting Aggro vs FlaSh ACS replaced by "ASL Season Open" - Starts 21/02 BGH Auto Balance -> http://bghmmr.eu/ CasterMuse Youtube TvZ is the most complete match up
Tourneys
Escore Tournament StarCraft Season 1 [Megathread] Daily Proleagues [LIVE] [S:21] ASL Season Open Day 1 Small VOD Thread 2.0
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Battle Aces/David Kim RTS Megathread Path of Exile Nintendo Switch Thread Beyond All Reason New broswer game : STG-World
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Mexico's Drug War Canadian Politics Mega-thread Russo-Ukrainian War Thread Ask and answer stupid questions here!
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Inside the Communication of …
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1156 users

[Math Puzzle] Day13 - Page 3

Blogs > evanthebouncy!
Post a Reply
Prev 1 2 3 4 Next All
Cambium
Profile Blog Joined June 2004
United States16368 Posts
June 08 2009 09:57 GMT
#41
To those of you who gave generic CS solutions (be it greedy, breadth-depth search, etc.), it doesn't work because you don't know the "exit condition" because the robot doesn't know when it has hit a wall and could not move further. Your program will most likely result in an infinite loop.
When you want something, all the universe conspires in helping you to achieve it.
DeathSpank
Profile Blog Joined February 2009
United States1029 Posts
June 08 2009 10:02 GMT
#42
On June 08 2009 18:57 Cambium wrote:
To those of you who gave generic CS solutions (be it greedy, breadth-depth search, etc.), it doesn't work because you don't know the "exit condition" because the robot doesn't know when it has hit a wall and could not move further. Your program will most likely result in an infinite loop.

well then its going to do that anyways. I'm sure I could do the math to figure out the limit I need for my solution but I really am to lazy. Programmers are lazy dudes. No one would ever program anything without an exit condition. Even if you found a correct solution you would never know when you hit the exit. So you would keep going and going. The robot can't know where it is. I therefor assume that the robot will exit automatically when I have reached my destination.
yes.
Ivs
Profile Joined January 2008
Australia139 Posts
Last Edited: 2009-06-08 14:20:22
June 08 2009 14:12 GMT
#43
+ Show Spoiler +

I'll have a go at this.

Result 1: Given any two start position in a fixed maze and two robots on one each, there exists a finite instruction such that, when executed simultaneously by the two robots (and no collision between the robots, so they are like probes on mining mode), they will eventually stack.

Assume the contrary. Find two starting positions with the minimal shortest path (ie, for each pair calculate the shorest path, then find the pair with the minimal value) such that the above fails. Call the two squares A and B and put robots there. Say the Euclidean (ie, measure with ruler distance) distance between them currently be say, d.

Now let the robot at A move towards B using the shortest path and let the other robot replicate the moves. The shortest path between robots does not increase during this whole time since one robot is reducing it. The shortest path also does not decrease by our minimal assumption. When the first robot gets up to position B, let the other be at position C. Now the path looks just like the original, because as one robot was "erasing" the path, the other one was "tracing" an identical one. Hence the Vector BC = Vector AB. And C is now 2d distance away from A.

We can continue this process and yield points D, E, F etc which gets further away from A by d each time. This is a contradiction since our maze is finite.

Result 2: Given a fixed maze and a robot on each square of the maze, there exists a finite instruction such that, when executed simultaneously by all robots, they will all stack.

This follows directly from Result 1. We just pick out any two separated robots, use Result 1 to stack them. Since once stacked they don't unstack, we can just pretend they are one robot. Repeat until all robots are stacked.

For a particular maze, define the sequence of moves found in Result 2 the "imba sequence"

Now after performing the "imba sequence", say the stacked robots are on a square S (which only depends on the "imba sequence" and not the start points). For any other square T, we can just now 1a2a3a our stacked robots there. Call this sequence of moves "attack-T sequence".

Final Result: Define our algorithm as follows:

List out all possible strings made up of U,D,L,R of length k, for all k. Concatenate them all together (so list all the possible strings of length 1, then 2, then 3 etc). It's clear that this big string has countable length. We'll prove that this algorithm satisfies the problem.

For any square T on the maze, combine our "imba sequence" with our "attack-T sequence", call it "bisu sequence" or something. Clearly the sequence is finite, so it appears in our algorithm somewhere. Consider performing the algorithm up to the start of "bisu sequence". Now no matter where the robot is, the "bisu sequence" will bring it to square T. And since this works for any T, no matter where the end of the maze is, as long as it's finite, the robot will get there in finite number of moves.


Hopefully it is correct :-).

Edit: Just read Muirhead's, It's much shorter/nicer :-). At least this is different and has a few additional results.
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 14:53:29
June 08 2009 14:49 GMT
#44
+ Show Spoiler +
Start with a length of 1. Follow every possible sequence with that length. Increase length by 1. Repeat.

Example: U, R, D, L, (length+1), UU UR UD UL, (length+1), UUU, UUR, UUD, UUL, URU, URR, URD, URL, UDU, UDR, UDD, UDL, ULU, ULR, ULD, ULL, (length+1), etc..

This way we'll create every possible path through the maze. It doesn't matter that we change positions between the tries because for every position there is a solution and as soon as our path is long enough we will eventually find the exit path that matches our current position.

This would be easier if we had knowledge about the maze size because we could just always use the longest possible path for our length but since we don't have that we increase our path length until we reach the one that we need.
You can reach the rainbow. I'll be there to help.
WhenHellfreezes
Profile Joined November 2008
United States81 Posts
June 08 2009 19:15 GMT
#45
On June 08 2009 23:49 ven_ wrote:
Start with a length of 1. Follow every possible sequence with that length. Increase length by 1. Repeat.

Example: U, R, D, L, (length+1), UU UR UD UL, (length+1), UUU, UUR, UUD, UUL, URU, URR, URD, URL, UDU, UDR, UDD, UDL, ULU, ULR, ULD, ULL, (length+1), etc..

This way we'll create every possible path through the maze. It doesn't matter that we change positions between the tries because for every position there is a solution and as soon as our path is long enough we will eventually find the exit path that matches our current position.

This would be easier if we had knowledge about the maze size because we could just always use the longest possible path for our length but since we don't have that we increase our path length until we reach the one that we need.


There is a problem with your assumptions. That it doesn't matter that we change positions is incorrect for example consider the length of three. It is possible that after doing UUU, UUR, UUD, that you moved to a spot such that UUU is the correct way to exit but you won't do that sequence again since you already did it in your rotation. The way to fix that would be to have every permutation of sequences for each length. Thus for every length i you would have (4^i)! sequences of lengths i. The total sum of moves in this sequence passes 1 mil within just like 5-6 lengths. Therefore a random algorithm would be loads better. I seriously don't understand why you are disallowing that.
Doom!
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 19:30:32
June 08 2009 19:24 GMT
#46
I do say that it will follow every possible arrangement of sequences for each length. So it will repeat ifself again. It will in fact repeat every previously used sequence 4 times per increase in length.
You can reach the rainbow. I'll be there to help.
WhenHellfreezes
Profile Joined November 2008
United States81 Posts
June 08 2009 19:39 GMT
#47
You missed what I'm saying completly.

You have every possible sequence of moves of length 3 as per what you said. But what I'm saying is that there are 4^3 such sequences and that you need to have every such possible arrangment of those sequences in order to fix the problem of not knowing where you are.

You need to write every permutation of these 4^3 sequences or (4^3)! sequences of length 3.

I'm saying that you stop at 4^3 and you need (4^3)!.
Doom!
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 20:29:56
June 08 2009 20:29 GMT
#48
No, I don't stop anywhere. The length will increase indefinitely. The example only shows the first 3 steps in order to show how it works. It doesn't stop there.
You can reach the rainbow. I'll be there to help.
WhenHellfreezes
Profile Joined November 2008
United States81 Posts
June 08 2009 21:28 GMT
#49
no i know that you continue past 3. I'm saying that you to have your step for each length be longer.
Doom!
moriya
Profile Joined March 2009
United States54 Posts
June 08 2009 21:59 GMT
#50
Such a solution tells nothing about the core of questions...
I thought the original question is to ask a gernal solution for every possible box. For example, in 1D case the solution is UDDUUUDDDDUUUUU...How to prove that there is no such a sequence for 2D case?
On June 08 2009 16:09 evandi wrote:
Show nested quote +
On June 08 2009 15:06 moriya wrote:
Now I doubt that within finite steps the solution can be achieved...

The spiral path may be promising solution, if there exsits a solution.


Muirhead solved it.

Muirhead
Profile Blog Joined October 2007
United States556 Posts
Last Edited: 2009-06-08 22:19:09
June 08 2009 22:11 GMT
#51
My solution is exactly the equivalent of UDDUUUDDDDUUUUU... in the 1-dimensional case.
I provide a single sequence which solves every possible maze.

All solutions posted are either like mine and Ivs's, grossly inefficient but nicely deterministic, or they are based on randomness. The random solutions are in many senses nicer but are "only" guaranteed to succeed with probability 1. Which you prefer depends on whether you want to be a practical computer scientists or an AWESOME MATHEMATICIAN ^^.

Though to be honest, I don't know enough (any) comp sci. Could someone summarize how fast my algorithm runs compared to a random algorithm?
starleague.mit.edu
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 23:04:15
June 08 2009 23:01 GMT
#52
You didn't really provide any actual algorithm.
But even then, any algorithm to solve a maze of this kind would be so horribly inefficient and slow that it doesn't make sense to compare their runtime.
You can reach the rainbow. I'll be there to help.
Muirhead
Profile Blog Joined October 2007
United States556 Posts
June 08 2009 23:54 GMT
#53
Sure I provided an actual algorithm
starleague.mit.edu
Ivs
Profile Joined January 2008
Australia139 Posts
June 09 2009 02:04 GMT
#54
I don't think it is obvious that

On June 08 2009 23:49 ven_ wrote:
+ Show Spoiler +

This way we'll create every possible path through the maze. It doesn't matter that we change positions between the tries because for every position there is a solution and as soon as our path is long enough we will eventually find the exit path that matches our current position.



Every possible path does occur, but you haven't shown that upon the positional change, the right path will follow.

For example, considers two squares A and B, let the classes of sequences that finish the maze be c(A) and c(B). Each member c(A) and c(B) does occur infinitely often, but you could have say, each element of c(B) only follows position A and each of c(A) only follows position B. To complete it you would need to show that the sets c(A) and c(B) have common elements, which they in fact do.
Daveed
Profile Blog Joined December 2006
United States236 Posts
June 09 2009 17:32 GMT
#55
@ Muirhead:
I know that this problem doesn't specify it, but generally, robots should be constrained by processing ability and memory. Keeping an enumeration of 2^{m*n} possible mazes should be out of the question. As a math solution, this would work, but I don't think the quantifiers of the problem were set up as well as they could have been.

That being said, I believe some variant of bugnav should do the trick.
Muirhead
Profile Blog Joined October 2007
United States556 Posts
June 09 2009 17:52 GMT
#56
Hrm I'm pretty sure that to execute my solution the robot would only need to keep one maze in its head at a time, though it would need to remember a set of directions corresponding to every square on the maze.
starleague.mit.edu
mmp
Profile Blog Joined April 2009
United States2130 Posts
Last Edited: 2009-06-09 19:49:56
June 09 2009 19:02 GMT
#57
On June 08 2009 14:44 Muirhead wrote:
+ Show Spoiler +
Suppose we are given the maze but not the starting position. Then we can solve the puzzle by looking at each possible starting position in turn. In short, we pick some box and assume the robot started there, giving it commands to solve the puzzle. Then, we pick a second box to assume the robot started in, see where the robot would be after our commands based on the first assumption, and give it commands to exit the maze. Etc.

Since the set of possible mazes is countable, we can adjoin the solutions for every given maze end to end and be done.


Interesting that you can try exhaustively on all mazes without worrying where the previous maze left your robit, since you are guessing from an unknown starting location. Counter intuitive, but cool once you think about it.

Worst-case runtime:
+ Show Spoiler +

Let B be the enumeration of possible mazes. This isn't exactly 2 ^ (m x n), since any open square must lead to an exit, but it is O(2 ^ (m x n)). To prove this, consider all mazes that do not have a solution path and are therefore invalid. Now make every other row entire open. All previously-invalid open squares are now adjacent to a solution row, while preserving (m x n) / 2 of the cells.

For every board there are O(m x n) starting positions to try. Since you know which board you are currently trying, there exists a known solution path of length O(m x n). So we immediately know that it will require O(B x m^2 x n^2) moves.


I'll work on non-deterministic runtime and expected runtime in a bit.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
King K. Rool
Profile Blog Joined May 2009
Canada4408 Posts
Last Edited: 2009-06-09 19:07:46
June 09 2009 19:05 GMT
#58
I thought the maze was supposed to be arbitrary?

Solutions to this (assuming maze is given) seem inefficient like ven_ said. Assuming we follow an algorithm like muirhead's (can't really think of another solution, his is pretty cool)

Worst case the last box you check would be the correct box. Obvious upper bound for boxes are O(m^2 * n^2). Number of boxes to check would be O(m^2 * n^2). Of course you likely could math it down to a better upper bound.

Something similar to ...

loop1 : i = 1.. m^2 * n^2 //ith box you check
loop2: j = 1 .. i //follow 1..ith path
m^2*n^2 instructions //follow the path

Not sure if my math is right (not going to bother thinking too much, at work), but you get something like an arithmetic series 1+2+3+...+k, where k is m^2 * n^2. We know that the 1+2+...k is O(k^2), so you get O(m^4 n^4), but then this is assuming one instruction. We have at most m^2n^2 instructions so you get m^6n^6.

O(m^6n^6) + finding paths for all boxes (which seems like it'll be easier to do).
mmp
Profile Blog Joined April 2009
United States2130 Posts
Last Edited: 2009-06-09 20:04:59
June 09 2009 19:40 GMT
#59
On June 10 2009 02:32 Daveed wrote:
@ Muirhead:
I know that this problem doesn't specify it, but generally, robots should be constrained by processing ability and memory. Keeping an enumeration of 2^{m*n} possible mazes should be out of the question. As a math solution, this would work, but I don't think the quantifiers of the problem were set up as well as they could have been.

That being said, I believe some variant of bugnav should do the trick.


Most bug pathfinders are based on some limited information about the map. Our robit cannot detect collisions (or anything for that matter), so wall-crawling, tangent bug, etc. are simply out of the question. Because we have no information, the problem lends itself to non-heuristic approach.

As for memory constraints, you require (m x n) bits to store any one maze. Generating another is simply a matter of incrementing bits until you have exhausted all permutations. For any given maze, I believe that you can construct a spanning tree of the adjacency matrix in O(m x n) time. You can search the tree for a solution (not necessarily the shortest) from any starting location in just as much time (linear).

Computationally, 2 ^ (m x n) is bad, but you really cannot avoid this part of the problem. At best, you can do a depth-first approach and compute massively in parallel.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Daveed
Profile Blog Joined December 2006
United States236 Posts
June 09 2009 20:08 GMT
#60
@Muirhead:
Although it needs to keep only one maze in its head at a time, it also needs to know which maze it's on, in order to generate the next maze in its enumeration (that IS what you are doing, correct?).

@ mmp: I had overlooked the inability of the robot to detect where it was. Sure, point taken.
Prev 1 2 3 4 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 2h 6m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 498
elazer 221
UpATreeSC 150
ProTech135
SteadfastSC 99
Livibee 44
Temp0 40
Dota 2
canceldota22
febbydoto8
Counter-Strike
pashabiceps2520
Heroes of the Storm
Liquid`Hasu441
Other Games
summit1g5864
tarik_tv5584
Grubby2418
Beastyqt768
shahzam347
C9.Mang0173
ToD145
Sick118
ArmadaUGS115
RotterdaM98
ZombieGrub31
Organizations
Counter-Strike
PGL325
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• Hupsaiya 15
• Reevou 6
• Kozan
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
StarCraft: Brood War
• blackmanpl 41
• RayReign 24
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota2713
League of Legends
• Doublelift1808
• TFBlade1179
• Scarra356
Other Games
• imaqtpie1178
• Shiphtur164
Upcoming Events
OSC
2h 6m
The PondCast
12h 6m
Replay Cast
1d 2h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
OSC
2 days
SC Evo Complete
2 days
DaveTesta Events
2 days
Replay Cast
3 days
Sparkling Tuna Cup
3 days
[ Show More ]
uThermal 2v2 Circuit
3 days
Replay Cast
4 days
Wardi Open
4 days
Monday Night Weeklies
4 days
Replay Cast
5 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-02-22
LiuLi Cup: 2025 Grand Finals
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Acropolis #4 - TS5
Jeongseon Sooper Cup
Spring Cup 2026
WardiTV Winter 2026
PiG Sty Festival 7.0
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
ASL Season 21: Qualifier #1
ASL Season 21: Qualifier #2
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.