• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:14
CEST 07:14
KST 14:14
  • 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
[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18Serral wins EWC 202549
Community News
Maestros of The Game—$20k event w/ live finals in Paris20Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195Weekly Cups (Jul 28-Aug 3): herO doubles up6
StarCraft 2
General
2v2 & SC: Evo Complete: Weekend Double Feature Geoff 'iNcontroL' Robinson has passed away What mix of new and old maps do you want in the next 1v1 ladder pool? (SC2) : The GOAT ranking of GOAT rankings RSL Revival patreon money discussion thread
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament Monday Nights Weeklies Master Swan Open (Global Bronze-Master 2) $5,100+ SEL Season 2 Championship (SC: Evo)
Strategy
Custom Maps
External Content
Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below Mutation # 484 Magnetic Pull
Brood War
General
Flash On His 2010 "God" Form, Mind Games, vs JD Joined effort New season has just come in ladder BW General Discussion Flash Announces (and Retracts) Hiatus From ASL
Tourneys
[ASL20] Ro24 Group C BWCL Season 63 Announcement [CSLPRO] It's CSLAN Season! - Last Chance [ASL20] Ro24 Group A
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Dawn of War IV Path of Exile Stormgate/Frost Giant Megathread
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
Russo-Ukrainian War Thread US Politics Mega-thread The year 2050 Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2660 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 4h 46m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 143
StarCraft: Brood War
Sea 8624
Larva 408
PianO 284
ggaemo 87
Icarus 9
Dota 2
NeuroSwarm151
League of Legends
JimRising 0
Counter-Strike
Stewie2K1257
Heroes of the Storm
Khaldor134
Other Games
summit1g9555
WinterStarcraft771
singsing540
ViBE173
kaitlyn18
ROOTCatZ9
Organizations
Other Games
gamesdonequick838
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH306
• davetesta19
• Freeedom3
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Diggity4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1012
Upcoming Events
Sparkling Tuna Cup
4h 46m
SC Evo League
6h 46m
Chat StarLeague
10h 46m
Razz vs Julia
StRyKeR vs ZZZero
Semih vs TBD
Replay Cast
18h 46m
Afreeca Starleague
1d 4h
Queen vs HyuN
EffOrt vs Calm
Wardi Open
1d 5h
RotterdaM Event
1d 9h
Replay Cast
1d 18h
Afreeca Starleague
2 days
Rush vs TBD
Jaedong vs Mong
Afreeca Starleague
3 days
herO vs TBD
Royal vs Barracks
[ Show More ]
Replay Cast
3 days
The PondCast
4 days
Replay Cast
4 days
LiuLi Cup
5 days
Cosmonarchy
5 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
5 days
Team Hawk vs Team Dewalt
BSL Team Wars
5 days
Team Hawk vs Team Bonyth
SC Evo League
6 days
[BSL 2025] Weekly
6 days
Liquipedia Results

Completed

Jiahua Invitational
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSLAN 3
SEL Season 2 Championship
WardiTV Summer 2025
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL Season 18: Qualifier 2
CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall 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 © 2025 TLnet. All Rights Reserved.