• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:12
CET 20:12
KST 04:12
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns6[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3
StarCraft 2
General
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach
Tourneys
SC2 AI Tournament 2026 WardiTV Winter Cup OSC Season 13 World Championship uThermal 2v2 Circuit WardiTV Mondays
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
BW General Discussion I would like to say something about StarCraft StarCraft & BroodWar Campaign Speedrun Quest BGH Auto Balance -> http://bghmmr.eu/ Data analysis on 70 million replays
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread General RTS Discussion Thread Awesome Games Done Quick 2026! Should offensive tower rushing be viable in RTS games?
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 Survivor II: The Amazon Sengoku Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread The Big Programming Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
How do archons sleep?
8882
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
GOAT of Goats list
BisuDagger
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1415 users

[Math Puzzle] Day13

Blogs > evanthebouncy!
Post a Reply
1 2 3 4 Next All
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
Last Edited: 2009-06-08 04:29:09
June 08 2009 03:05 GMT
#1
from me: Please leave some comments as they mean a lot <3.

Last day's puzzle was first solved by Konfustikator, while Pseudo_Utopia might be easier to understand.

+ Show Spoiler [solution] +

Total color is 6, consider row_y which looks like
row_y = {(0,y), (1,y), (2,y), ... (6,y)}
clearly, row_y is a row with y axis value of y, and its x values ranges from 0 to 6.
Since each row has 7 elements, then 2 of them must be the same color.

Now consider this area formed by
{row_0, row_1, row_2, ... row_6^7}

This is a huge tall rectangle with height 6^7+1 and width 7. Since with 6 colors, all rows of 7 elements have 6^7 kinds of coloring scheme, then with a height of 6^7+1 two rows, say row_i, row_j must have identical coloring scheme.

Then since both row_i and row_j has 1 color that's repeated, that color will form the rectangle, whos verticies are identical color.

Considering draw out a picture if this is not intuitive enough, but this is a very clean solution.


Today's puzzle is a bit into the computer science side, but still fairly math oriented. It is as follows.

You have a maze, here is how it's constructed:
the maze is made within a rectangular grid of size mxn, where m and n are arbitarily chosen natural numbers.
Of any grid, it can either be part a path or a wall.
From any point inside the maze, provided that it's not a wall, will have a way out.
Then clearly, to walk outside of a maze, you'll have to go up, down, left, right in some way.

You also have a robot, here's the property of the robot:
You can code the robot to move in a certain way. For instance, coding it with the sequence:
left, left, up, up will make the robot attempt to move left twice, and up twice.
If the robot is blocked on the left, executing the move "left" multiple times will not move the robot.
The robot has no sense of perception, that is to say:
-It cannot know if it hits a wall
-It cannot know where it is inside the maze
-It does not know how far it has walked

Your Job:
Code the robot in such a way that for ANY valid maze [that is to say, for any m, n maze size and for any valid maze construction of that size] the robot will eventually be able to get out.
The fine print:
By ANY valid maze it means that regardless of size of m, n, and regardless of maze design, the robot will be able to move outside the maze eventually. That is to say, while you are coding, you cannot assume a certain m, n, or design.

Some example pictures:
[image loading]

Here is an example of a valid maze, with the maze area being black and white, and the outside area colored green. where the robot starts at the red point, and executing the instruction:
up-up-down-down-right-right-left-left
then ends up at point blue.

Again, post anything that comes across your mind, and if you're confident that you have the answer, put it in a spoiler. GL!
Again, leave a comment, it'll be much appreciated and kept me doing these blogs.

Edit:
No "random move" algorithms please.


Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
Zozma
Profile Blog Joined November 2008
United States1626 Posts
June 08 2009 03:34 GMT
#2
Hmm. Left, down, right, up(times infinity) would ensure that our robot friend could always make progress, but if he gets caught in four open squares it wouldn't work. This is an interesting one, but I don't think I know enough to solve it. T_T
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 03:38 GMT
#3
Far worse than that, even in the example with the red dot, LDRU repeated endlessly just results in it moving back and forth between the dot and the square below it.

My first thought on reading the question was "yay implement BFS ezpz" and then I got to the part where the robot can't sense anything. ;; Trying to think of some kind of psuedo-BFS (or more likely DFS in this case) I could implement without feedback.
Malongo
Profile Blog Joined November 2005
Chile3472 Posts
June 08 2009 03:49 GMT
#4
I just noted that doing the Zig-Zag route up-right m*n times puts the robot in some "accumulation points" at corners. Im thinking about up-right m*n times then twisting the direction so the up-right becomes left-up. I think the brute force solution is some sort of up-right, left-up, down-left, right-down (each one m*n times) and then if you do the same again the robot ends up at the same square so you can do repeat but this time in other direction. Damn its hard to explain.
Help me! im still improving my English. An eye for an eye makes the whole world blind. M. G.
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 03:50 GMT
#5
Spoilering in case I'm getting close to the answer, but I don't think I'm there yet.

+ Show Spoiler +
Thinking about it more, psuedo-BFS may be the way to go after all. Because of the maze definition, there is some sequence of moves that will get the robot out. You could have it essentially attempt all possible combinations in a logical order (i.e. U; R; D; L; UU; UR; UD; UL; RU... etc.) that's easily written through loops, and do the inverse after each attempt (i.e. say it tries the sequence UDLRUDUDRR, the inverse would be LLUDUDLRUD) to attempt to return to the starting point, then start the next sequence. The problem with that is that since you have no feedback, performing the inverse sequence of moves is unlikely to return you to the starting position.
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 03:54 GMT
#6
On June 08 2009 12:50 Macavenger wrote:
Spoilering in case I'm getting close to the answer, but I don't think I'm there yet.

+ Show Spoiler +
Thinking about it more, psuedo-BFS may be the way to go after all. Because of the maze definition, there is some sequence of moves that will get the robot out. You could have it essentially attempt all possible combinations in a logical order (i.e. U; R; D; L; UU; UR; UD; UL; RU... etc.) that's easily written through loops, and do the inverse after each attempt (i.e. say it tries the sequence UDLRUDUDRR, the inverse would be LLUDUDLRUD) to attempt to return to the starting point, then start the next sequence. The problem with that is that since you have no feedback, performing the inverse sequence of moves is unlikely to return you to the starting position.


You can't do inverse.
For instance, say your robot has a wall on the immediate left.
The sequence LLL will be inversed to RRR, yet LLLRRR will certainly NOT make you go back to the original point.
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 03:56 GMT
#7
For Malongo:

+ Show Spoiler +
I looked at a couple of approaches very similar to that, and I don't think it quite works. Running some test cases on the example provided, the collection points can end up not being anywhere near the exit, and having no direct path between any collection point and the exit. If you got lucky and tried R-D followed by L-D immediately from the start, you'd get it, but you can't assume that kind of luck, and the starting position shown is not actually a collection point itself, so you can't really get back to it. Unless there's some way of juggling the order of attempts I haven't thought of, I don't think what you have is going to reliably produce a solution.
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 03:56 GMT
#8
On June 08 2009 12:54 evanthebouncy! wrote:
Show nested quote +
On June 08 2009 12:50 Macavenger wrote:
Spoilering in case I'm getting close to the answer, but I don't think I'm there yet.

+ Show Spoiler +
Thinking about it more, psuedo-BFS may be the way to go after all. Because of the maze definition, there is some sequence of moves that will get the robot out. You could have it essentially attempt all possible combinations in a logical order (i.e. U; R; D; L; UU; UR; UD; UL; RU... etc.) that's easily written through loops, and do the inverse after each attempt (i.e. say it tries the sequence UDLRUDUDRR, the inverse would be LLUDUDLRUD) to attempt to return to the starting point, then start the next sequence. The problem with that is that since you have no feedback, performing the inverse sequence of moves is unlikely to return you to the starting position.


You can't do inverse.
For instance, say your robot has a wall on the immediate left.
The sequence LLL will be inversed to RRR, yet LLLRRR will certainly NOT make you go back to the original point.

I said that in my explanation It's why I said I didn't think I had it yet.
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 04:03:42
June 08 2009 03:57 GMT
#9
randomly choose the direction. even if it takes ages, at some point you will get out :o
You can reach the rainbow. I'll be there to help.
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 04:02 GMT
#10
On June 08 2009 12:56 Macavenger wrote:
Show nested quote +
On June 08 2009 12:54 evanthebouncy! wrote:
On June 08 2009 12:50 Macavenger wrote:
Spoilering in case I'm getting close to the answer, but I don't think I'm there yet.

+ Show Spoiler +
Thinking about it more, psuedo-BFS may be the way to go after all. Because of the maze definition, there is some sequence of moves that will get the robot out. You could have it essentially attempt all possible combinations in a logical order (i.e. U; R; D; L; UU; UR; UD; UL; RU... etc.) that's easily written through loops, and do the inverse after each attempt (i.e. say it tries the sequence UDLRUDUDRR, the inverse would be LLUDUDLRUD) to attempt to return to the starting point, then start the next sequence. The problem with that is that since you have no feedback, performing the inverse sequence of moves is unlikely to return you to the starting position.


You can't do inverse.
For instance, say your robot has a wall on the immediate left.
The sequence LLL will be inversed to RRR, yet LLLRRR will certainly NOT make you go back to the original point.

I said that in my explanation It's why I said I didn't think I had it yet.

HAHHA i read everything but your last sentence. >_<
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 04:04 GMT
#11
+ Show Spoiler +
Also, you might want to revise the question a wee bit, since I think technically if you just tell the robot to choose a random direction at each move, statistically it will get out eventually... but I don't think that's really in the spirit of the problem.
ven
Profile Blog Joined December 2008
Germany332 Posts
Last Edited: 2009-06-08 04:16:21
June 08 2009 04:14 GMT
#12
+ Show Spoiler +
loop LU * i, RU * i, RD * i, LD * i with i increasing every cycle from 1 to max(m,n) and reset i to 1 when if it reaches the upper boundary.

I guess you can trap this as well but I'm too tired to think properly :o
You can reach the rainbow. I'll be there to help.
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 04:16 GMT
#13
On June 08 2009 13:14 ven_ wrote:
+ Show Spoiler +
loop LU * i, RU * i, RD * i, LD * i with i increasing every cycle from 1 to max(m,n) and reset i to 1 when if it reaches the upper boundary.

I guess you can trap this as well but I'm too tired to think properly :o

It does not know what is a boundry.
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 04:17 GMT
#14
On June 08 2009 13:04 Macavenger wrote:
Also, you might want to revise the question a wee bit, since I think technically if you just tell the robot to choose a random direction at each move, statistically it will get out eventually... but I don't think that's really in the spirit of the problem.

done
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
ven
Profile Blog Joined December 2008
Germany332 Posts
June 08 2009 04:20 GMT
#15
On June 08 2009 13:16 evanthebouncy! wrote:
Show nested quote +
On June 08 2009 13:14 ven_ wrote:
+ Show Spoiler +
loop LU * i, RU * i, RD * i, LD * i with i increasing every cycle from 1 to max(m,n) and reset i to 1 when if it reaches the upper boundary.

I guess you can trap this as well but I'm too tired to think properly :o

It does not know what is a boundry.

Well, the algorithm does. I'm referring to i reaching max(m,n).
You can reach the rainbow. I'll be there to help.
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 04:26 GMT
#16
On June 08 2009 13:20 ven_ wrote:
Show nested quote +
On June 08 2009 13:16 evanthebouncy! wrote:
On June 08 2009 13:14 ven_ wrote:
+ Show Spoiler +
loop LU * i, RU * i, RD * i, LD * i with i increasing every cycle from 1 to max(m,n) and reset i to 1 when if it reaches the upper boundary.

I guess you can trap this as well but I'm too tired to think properly :o

It does not know what is a boundry.

Well, the algorithm does. I'm referring to i reaching max(m,n).

Ah I should probably fix it...
By "Arbitary" I mean the algorithm provider does not know the size of m and n... I'll go fix it now. Thx.
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
illu
Profile Blog Joined December 2008
Canada2531 Posts
June 08 2009 04:27 GMT
#17
Pretty easy.

+ Show Spoiler +

Since at any point there is one way out, we can create a non-deterministic Turing Machine as follows:

1. At each position, move to any of the other possible positions that are not walls.

Then this Turing Machine will always accept, by construction of the maze. We know that non-determinism gives no extra computation powers so we can come up with an algorithm by a Turing Machine to create this path, which executes on finite time.

The actual algorithm is extremely simple so I won't get too detailed in this. (wiki if you like). Just go with a breadth-first search and you will get a path that allows you to exit. As shown before this algorithm will complete on finite time which is what we want.
:]
ven
Profile Blog Joined December 2008
Germany332 Posts
June 08 2009 04:31 GMT
#18
On June 08 2009 13:27 illu wrote:
Pretty easy.

+ Show Spoiler +

Since at any point there is one way out, we can create a non-deterministic Turing Machine as follows:

1. At each position, move to any of the other possible positions that are not walls.

Then this Turing Machine will always accept, by construction of the maze. We know that non-determinism gives no extra computation powers so we can come up with an algorithm by a Turing Machine to create this path, which executes on finite time.

The actual algorithm is extremely simple so I won't get too detailed in this. (wiki if you like). Just go with a breadth-first search and you will get a path that allows you to exit. As shown before this algorithm will complete on finite time which is what we want.

You don't know where the walls are.
You can reach the rainbow. I'll be there to help.
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 08 2009 04:32 GMT
#19
On June 08 2009 13:27 illu wrote:
Pretty easy.

+ Show Spoiler +

Since at any point there is one way out, we can create a non-deterministic Turing Machine as follows:

1. At each position, move to any of the other possible positions that are not walls.

Then this Turing Machine will always accept, by construction of the maze. We know that non-determinism gives no extra computation powers so we can come up with an algorithm by a Turing Machine to create this path, which executes on finite time.

The actual algorithm is extremely simple so I won't get too detailed in this. (wiki if you like). Just go with a breadth-first search and you will get a path that allows you to exit. As shown before this algorithm will complete on finite time which is what we want.


Too technical, i have no clue what you just said.
just reading your (1) though: you cannot garentee that you "moved" in a sense that the robot does not know if its attempted move is not blocked by the wall.
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
June 08 2009 04:37 GMT
#20
On June 08 2009 13:32 evanthebouncy! wrote:
Show nested quote +
On June 08 2009 13:27 illu wrote:
Pretty easy.

+ Show Spoiler +

Since at any point there is one way out, we can create a non-deterministic Turing Machine as follows:

1. At each position, move to any of the other possible positions that are not walls.

Then this Turing Machine will always accept, by construction of the maze. We know that non-determinism gives no extra computation powers so we can come up with an algorithm by a Turing Machine to create this path, which executes on finite time.

The actual algorithm is extremely simple so I won't get too detailed in this. (wiki if you like). Just go with a breadth-first search and you will get a path that allows you to exit. As shown before this algorithm will complete on finite time which is what we want.


Too technical, i have no clue what you just said.
just reading your (1) though: you cannot garentee that you "moved" in a sense that the robot does not know if its attempted move is not blocked by the wall.

+ Show Spoiler +
It's been a couple years since I worked with Turning machines and non-determinism, so I'm a bit rusty, but reading his solution, I'm quite certain it correctly proves the existence of an algorithm. Non-deterministic Turing Machines can do some pretty interesting things, and can easily have paths that lead nowhere, which would be the equivalent of attempting to move into a wall.
1 2 3 4 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 18h 48m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 457
UpATreeSC 111
JuggernautJason13
IndyStarCraft 8
StarCraft: Brood War
Britney 34725
Shuttle 477
Mong 53
Shine 25
910 25
Dota 2
BananaSlamJamma250
LuMiX1
League of Legends
C9.Mang0653
Counter-Strike
fl0m1696
pashabiceps1150
adren_tv142
Super Smash Bros
Mew2King42
Heroes of the Storm
Liquid`Hasu295
KnowMe112
Other Games
Grubby4086
Gorgc3455
Liquid`RaSZi1894
FrodaN1567
Beastyqt781
RotterdaM300
DeMusliM287
JimRising 212
Fuzer 211
Sick208
ArmadaUGS202
B2W.Neo155
QueenE94
Organizations
Other Games
gamesdonequick42767
BasetradeTV40
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• HappyZerGling 94
• naamasc267
• Reevou 1
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• HerbMon 37
• FirePhoenix16
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Nemesis2037
Other Games
• imaqtpie1785
• Shiphtur256
Upcoming Events
OSC
18h 48m
SOOP
2 days
SHIN vs GuMiho
Cure vs Creator
The PondCast
2 days
Sparkling Tuna Cup
3 days
IPSL
4 days
DragOn vs Sziky
Replay Cast
4 days
Wardi Open
4 days
Monday Night Weeklies
4 days
Liquipedia Results

Completed

Proleague 2026-01-06
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
OSC Championship Season 13
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W3
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.