This post is by from RubyLearning Blog
Click here to view on the original site: Original Post
Ruby Programming Challenge For Newbies
RPCFN: Japanese Mosaic Problem (#14)
By Joseph Wilk
About Joseph Wilk
Joseph Wilk is a member of the core development team for Cucumber. He has been developing for the web for over 10 years in both big and small companies and as an entrepreneur. After stints working with Java and Python he finally found Ruby. He now spends his time in-between eating Cucumbers working at Songkick.com. Having more fun than is healthy working as a Software Gardener building web systems, working on open source projects and giving talks around the world about testing. He suffers from test obsession and has given up hope of any treatment.
Joseph Wilk has this to say about the challenge:
The Japanese Mosaic problem is a logic puzzle based on a grid with the cells potentially containing numbers ranging 0 to 9. The numbers reflect for a cell how many of its neighbours and itself are shaded in. The fun aspect of these problems is once solved you end up with some pretty ASCII art. You’re challenge is to write an algorithm to solve any mosaic puzzle. The challenge provides the opportunity to explore data structures to represent the problem space and looking at how we can navigate the structure in search of a solution. There are lots of opportunities to also think about the efficiency in searching for a solution. A Cucumber feature has already been written for you with lots of scenarios exploring through examples the rules of the Japanese Mosaic problem. If you are not familiar with Cucumber checkout http://cukes.info/. This Cucumber feature is both your specification and your executable tests. You’re mission is to get all the Scenarios passing. There are many ways to solve the problem and I look forward to seeing how people tackle these in the different languages. Good luck and safe Cuking.
- The participant with the best Ruby solution (if there is a tie between answers, then the one who posted first will be the winner) will be awarded any one of PeepCode’s Ruby on Rails screencasts.
- From the remaining working Ruby solutions, three participants would be selected randomly and each one would be awarded any one of Pragmatic’s The Ruby Object Model and Metaprogramming screencasts.
The four persons who win, can’t win again in the next immediate challenge but can still participate.
The Ruby Challenge
All the instructions and the code to get you started are in a Github repository: http://github.com/josephwilk/japanese-mosaic-logic-puzzle
How to Enter the Challenge
Read the Challenge Rules. By participating in this challenge, you agree to be bound by these Challenge Rules. It’s free and registration is optional. You can enter the challenge just by posting the following as a comment to this blog post:
- Your name:
- Country of Residence:
- GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
- Code works with Ruby 1.8 / 1.9 / Both:
- Email address (will not be published):
- Brief description of what you do (will not be published):
- As soon as we receive your GIST URL, we will fork your submission. This means that your solution is frozen and accepted. Please be sure that is the solution you want, as it is now recorded in time and is the version that will be evaluated.
- All solutions posted would be hidden to allow participants to come up with their own solutions.
- You should post your entries before midnight of 31st Oct. 2010 (Indian Standard Time). No new solutions will be accepted from 1st Nov. onwards.
- On 1st Nov. 2010 all the solutions will be thrown open for everyone to see and comment upon.
- The winning entries will be announced on this blog in the first week of Nov. 2010. The winners will be sent their prizes by email.
More details on the RPCFN?
Please refer to the RPCFN FAQ for answers to the following questions:
- What Is The Ruby Programming Challenge For Newbies (RPCFN)?
- How does RPCFN benefit you?
- Challenge Rules
- Best Solution
- Can I Submit A Ruby Programming Challenge Topic?
RPCFN is entirely financed by RubyLearning and sometimes sponsors, so if you enjoy solving Ruby problems and would like to give something back by helping with the running costs then any donations are gratefully received.
Special thanks to:
- Joseph Wilk.
- GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
- The RubyLearning team.
Contact Satish Talim at satish [dot] talim [at] gmail.com OR if you have any doubts / questions about the challenge (the current problem statement), please post them as comments to this post and the author will reply asap.
There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.
In the competition
Just for Fun
RPCFN: Economics 101 (#13) by Dr. Bruce Scharlau.
Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.
- The (#15) challenge by Julio Javier Cicchelli, Netherlands is scheduled for Nov. 2010.