You are viewing a single comment's thread from:
RE: Coding Challenge #3 – An AI to solve a maze (ruby only)
Hi @reggaemuffin, I never used ruby before, but I remember I solved this problem before during my studies. So I tried, at the end, the language's grammar is not so difficult to get (at least for this problem, where you need just to write a few methods 😼)
Here is my solution:
https://repl.it/KWPT/10
How it works:
I use the following rule: (as you can easliy see in the method next_direction
)
- if possible, always turn anti-clockwise and then go forward
- if you can't, then try to just go forward (in the same direction as before)
- if you can't, try turn clockwise and the go forward
- if none of the above is possible, it means you are in a dead end (walls in front, at your left and at your right). Then just go back.
Basically, you just need to follow the wall.
I use this method all the times! I'm a cat if you didn't notice, and I find mazes all the time when I walk around 😹 . Never been stuck!
Hope you like the solution. Please consider it's the first time I write in ruby
Some impressive stuff coming from a cat. Well done
Thank you! I'm a peculiar cat 😼
Awesome! I'll check it out once I get back. 🐐
Thanks! I followed you.. looking forward for the next challenges 😻
🐾
It looks really straightforward :) I'll try posting more challenges soon :)
Hi @reggaemuffin
I made a coding contest. Quite simple.. But I hope to do more difficult ones later.
Can you have a look and maybe help me spread the word? Thanks!
https://steemit.com/contest/@armandocat/coding-challenge-1-win-sbd-if-you-solve-the-problem