• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:39
CEST 13:39
KST 20:39
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes90BSL 2025 Warsaw LAN + Legends Showmatch2Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues #1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy
Tourneys
RSL: Revival, a new crowdfunded tournament series SC2's Safe House 2 - October 18 & 19 Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
ASL20 General Discussion Soulkey on ASL S20 BW General Discussion ASL TICKET LIVE help! :D NaDa's Body
Tourneys
[ASL20] Ro16 Group D BSL 2025 Warsaw LAN + Legends Showmatch [ASL20] Ro16 Group C Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine UK Politics Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
Too Many LANs? Tournament Ov…
TrAiDoS
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2129 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
Map Test Tournament
11:00
$500 4v4 Open
IndyStarCraft 306
WardiTV305
Rex92
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 306
OGKoka 224
Rex 92
ProTech77
StarCraft: Brood War
Britney 24383
Rain 5271
Horang2 1517
EffOrt 1325
actioN 850
Hyuk 495
Snow 327
BeSt 259
Larva 188
Leta 178
[ Show more ]
Pusan 171
Rush 165
Light 114
Soulkey 93
Hyun 91
Barracks 90
Mind 83
Nal_rA 60
ZerO 59
ggaemo 59
Liquid`Ret 53
sorry 26
ivOry 26
Sharp 26
Sea.KH 25
Movie 21
Backho 20
Free 17
JYJ16
soO 15
Sacsri 10
SilentControl 6
Terrorterran 5
Shine 5
Icarus 5
Noble 5
Dota 2
singsing2748
XcaliburYe160
boxi98159
Heroes of the Storm
Khaldor95
Other Games
olofmeister784
B2W.Neo702
crisheroes443
Hui .216
Lowko105
Mew2King50
NeuroSwarm36
Trikslyr23
EmSc Tv 15
ZerO(Twitch)11
Organizations
StarCraft: Brood War
CasterMuse 21
Other Games
EmSc Tv 15
StarCraft 2
EmSc2Tv 15
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1189
Other Games
• WagamamaTV177
Upcoming Events
Korean StarCraft League
15h 22m
BSL Open LAN 2025 - War…
20h 22m
RSL Revival
22h 22m
Reynor vs Cure
BSL Open LAN 2025 - War…
1d 20h
RSL Revival
1d 22h
Online Event
2 days
Wardi Open
2 days
Monday Night Weeklies
3 days
Sparkling Tuna Cup
3 days
LiuLi Cup
5 days
[ Show More ]
The PondCast
5 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.