• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:58
CEST 16:58
KST 23:58
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China8Flash Announces Hiatus From ASL64Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
SC uni coach streams logging into betting site BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps Flash Announces Hiatus From ASL
Tourneys
CSL Xiamen International Invitational [BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 740 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
Wardi Open
11:00
#43
WardiTV1324
OGKoka 526
Harstem467
IndyStarCraft 220
Rex153
CranKy Ducklings128
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 526
Harstem 467
mouzHeroMarine 306
Hui .244
IndyStarCraft 220
Rex 153
StarCraft: Brood War
Bisu 3004
Jaedong 2356
Flash 2260
EffOrt 904
Hyuk 681
ZerO 547
Soulkey 517
Snow 449
actioN 444
Larva 417
[ Show more ]
Stork 393
Soma 255
firebathero 240
GuemChi 234
Mind 110
sSak 98
TY 76
PianO 53
hero 52
Sharp 51
JulyZerg 50
Barracks 46
Sea.KH 39
JYJ28
sorry 28
Aegong 27
yabsab 24
Terrorterran 24
HiyA 22
soO 19
GoRush 14
Rock 13
IntoTheRainbow 11
Shine 6
Dota 2
Gorgc5307
qojqva3099
syndereN481
League of Legends
singsing2430
Dendi1165
Counter-Strike
markeloff128
fl0m90
Super Smash Bros
Mew2King223
Other Games
hiko1813
B2W.Neo1103
Beastyqt647
crisheroes367
Lowko361
ArmadaUGS132
Liquid`VortiX128
ZerO(Twitch)21
Trikslyr3
Organizations
Other Games
gamesdonequick41702
StarCraft: Brood War
UltimateBattle 513
StarCraft 2
IntoTheiNu 14
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Reevou 1
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3357
• WagamamaTV442
League of Legends
• Nemesis6990
Upcoming Events
RotterdaM Event
1h 2m
Replay Cast
9h 2m
Sparkling Tuna Cup
19h 2m
WardiTV European League
1d 1h
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 9h
The PondCast
1d 19h
WardiTV European League
1d 21h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
2 days
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
[ Show More ]
Replay Cast
3 days
RSL Revival
3 days
Classic vs Cure
FEL
4 days
RSL Revival
4 days
FEL
4 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
6 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.