Welcome to the third Coding Challenge.
Here I will post a coding challenge every few days that you can solve. There will be easy ones and hard ones, pretty mixed.
How does it work?
- Try to solve the challenge in ruby, you learn a bit if you have not heard of the language
- Post a comment with a link to your code (use https://repl.it) and some info on how the code works or what is remarkable
- Optional: Create a post with the tag #coding-solution
- In that post walk other users through the process of solving your challenge. That way they can learn and try it out on the next one
- Optional: Read and review other peoples code, try to find bugs, give feedback and learn
Why even bother?
- Training is everything, the more you train your mind to think in code, the better you are prepared
- You may learn a few new tricks from reading other solutions
- I will send tips for really good solutions (and use the liquid rewards of this post for it too)
- You may get recruited if someone likes your code (f.e. I am looking for talents)
Challenge #3 – An AI to solve a maze
This challenge will be a bit more complicated and hands on. See the starting code here: https://repl.it/KWPT/1
Implement an AI
class that solves a maze:
- the repl.it link gives you a starting point and implements the game.
- Only use what repl.it can execute
- All code that you need is documented to ensure nothing is unclear, please ping me if you have any more question.
- You fill in the
step
method and everything else you need to get out of the maze.- Each step you get the current maze and possible directions and you return the direction you want to walk in.
- You will probably have to remember where you are. A visual representation of the board is given, but that is not easy to parse to encourage you to remember the board yourself.
??????+--+--+--+
??????| AI |
??????+--+--+ +
????????? |
?????????+--+--+
- The game code should not be edited (everything under
DO NOT EDIT DOWN HERE!
)
Remarks:
- As a sample implementation you can try out, a random walker is already implemented.
- Try solving a maze with the smallest amount of steps possible.
- Try exploring the whole map before you leave the maze.
- Bonus points for:
- good coding practices and modularity
- beautiful (readable, self-documenting) code
Please keep the #coding-challenge tag clean of solutions.
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
)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
Problem looks fairly interesting. Time to revise my ruby skills... (Hopefully will get time.)
Looking forward to your AI 😊
I don't know, is Ruby really worth learning or not? I mean here in Palestine until now I've seen no single job asking for a Ruby programming skill, all what they require is node.js an AJAX mostly
Well there are many ruby jobs out there. Your mileage may wary if you only look at the hip and new js stuff though.
For example @buildteam is looking for ruby developers ;)
And on a different note: If you only learn exactly what you need and nothing else, then you will probably not succeed at being a programmer. What if in two years everyone codes in rust and a year later a new language emerges that everyone loves. So understanding different languages alone can be worth it.
I suggest reading https://www.quora.com/What-makes-Rails-a-framework-worth-learning-in-2017/answer/David-Heinemeier-Hansson
You're right, but I'm still at the beginning of my career and I really feel a lot more nervous about choosing what's the best for me
Then my suggestion for you is: build stuff.
Your first language does not really matter a lot, if you want, learn multiple at the same time and try out things. Or stick to one and branch out once you have it learned reasonably well.
If you have some time on your hands, take the challenge and try to code the AI in ruby. If you have any questions that google cannot answer, ask here, I can happily help you :) And if you share your code, we all can help you improve by giving you small tips and suggestions with each new iteration :)
Thank you, that means a lot to me... I promise I will do my best ❤️
Interesting challenge, but I'll have to pass on this one. Learning Ruby isn't high on my list, and for a complete beginner this problem seems a tad too complicated.
Looking forward to the next one ;)
If you want, suggest me a language for the next challenge :)
I think ruby is really nice but I don't mind writing skeletons in other languages if that helps bringing in more participants.
My main language is JavaScript, but for an easy/medium challenge I'm definitely willing to give Python, Haskell and Go a chance.
In all honesty I'm impressed with these challenges and love reading others' solutions, but I'm curious what the response will be at this level. For a serious developer these problems definitely are solvable, but many with such skills already have plenty of work to do.
I can barely find time to do simple Codewars challenges in between work and my hobby projects, let alone larger ones like these.
Anyway, as long as people take on the challenges I'll be reading their solutions, so don't let my inability to participate home anyone back :)
I recommend that you generalise the challenges so that everyone has a chance but every so often and then make specified challenges
My other challenges are open for all languages, this one just has a skeleton written in ruby.
I'm curious, why limit this challenge to ruby? Generally programming challenges are open to all languages-- as the point of the challenge is to come up with a solution, not to come up with a solution in X programming language.
Well, the game is coded in ruby. You are free to use other languages, if you port the game first. But I don't expect anyone to do that...
great :)
follow me @fbslo
I will, plz you will upvote and follow
nice
great post... followed n upvoted.. :-)
Well done buddy @reggaemuffin
I will follow you.
I upvote you and reblog your post.. please upvote and reblog my post to. Follow me @blackbone. Together can be success...
Great post go ahead
i will fan you bro. i like to your coding....follow and vote .
Nice post but I am not good at computer coding
great
follow me and upvot plz
@brow10
Why not create a test in hackerrank.com and link to it? That would be a better way to submit answers then in the textfield below.
Seems like a lot of logging in and setting up accounts before you can start. I'll check it out for the next challenge but not for this one :)
From what I saw on hackerrank it is something that can work with well defined problems, but not with this one. If you want you can create a challenge but that is too much overhead for me at the moment.
all your challenges are to cool...
upvoted..!!!
should I even be bother participating if i dont know anything about coding, I am trying to start learning now from java script mmm
Well, the challenge won't be easy if you start at zero, but you can always try (and we are here to help you)
follow upvote resteem
Not a fan of ruby but sounds to me the classic A* path finder is the best solution for this type of issue.
Here is an abstract version I created in C# a while back
Woz.PathFinding
I will be re-writing this in F# at some point in my Building a roguelike in F# from scratch series :)
The C# one could be better but I was playing with immutable state in C# at the time so this one is a little over verbose, no native immutable state in C#.
Well the twist is that the maze is hidden. So you have to discover before you can path :)
If you want, you could port the game logic to C# or F# so others can participate too :)
Hi @reggaemuffin , i saw that you are interested in trading charts sometimes. So, maybe it will be interesting to you my works? i make short analysis for main and interesting coins everyday. I will be happy to see you in my blog. Have a nice day! (upvoted you and followed).
Hiii
Spamming comments is frowned upon by the community.
Continued comment spamming may result in action from the cheetah bot.
no.