RPCFN: Average Arrival Time For A Flight (#2) – Reprint

Note: This article first appeared on 8th Oct. 2009 but the original is not accessible; hence the reprint.

Ruby Programming Challenge For Newbies

RPCFN: Average Arrival Time For A Flight (#2)

By Chris Strom

Thank you for the very encouraging response to the first-everRuby Programming Challenge For Newbies (RPCFN)“. The second Ruby challenge is from Chris Strom.

About Chris Strom

Chris StromChris Strom (twitter / blog) in his day job, is the Director of Software Engineering for mdlogix, a small company in Baltimore, Maryland. They develop software that manages clinical research trials and associated data. They primarily code with Ruby on Rails. His background is in web development, mostly in Perl until ~2005 when he made the switch to Ruby.

Chris has this to say about the challenge:

RPCFN is a good idea as reading books and documentation can only take you so far when learning a new language. To really learn, you need to use the language. RPCFN provides a fabulous forum for using Ruby in the form of regular, engaging (but not arcanely difficult) challenges. Better yet, it provides feedback on how to use Ruby well, as each fortnight the best solution to a challenge is chosen. RPCFN is a wonderful introduction to the Ruby language and to the Ruby community. Welcome newbies!

Railsware for premium-quality web applications
RPCFN
Winners
Update

Continue reading “RPCFN: Average Arrival Time For A Flight (#2) – Reprint”

RPCFN: Average Arrival Time For A Flight (#2) – Reprint

Note: This article first appeared on 8th Oct. 2009 but the original is not accessible; hence the reprint.

Ruby Programming Challenge For Newbies

RPCFN: Average Arrival Time For A Flight (#2)

By Chris Strom

Thank you for the very encouraging response to the first-everRuby Programming Challenge For Newbies (RPCFN)“. The second Ruby challenge is from Chris Strom.

About Chris Strom

Chris StromChris Strom (twitter / blog) in his day job, is the Director of Software Engineering for mdlogix, a small company in Baltimore, Maryland. They develop software that manages clinical research trials and associated data. They primarily code with Ruby on Rails. His background is in web development, mostly in Perl until ~2005 when he made the switch to Ruby.

Chris has this to say about the challenge:

RPCFN is a good idea as reading books and documentation can only take you so far when

Railsware for premium-quality web applications
RPCFN
Winners
Update

Continue reading “RPCFN: Average Arrival Time For A Flight (#2) – Reprint”

Felipe Elias Philipp Winner RPCFN #1 (Reprint)

Note: This article first appeared on 8th Oct. 2009 but the original is not accessible; hence the reprint.

In this brief interview, Satish Talim of RubyLearning talks to Felipe Elias Philipp of Brazil, winner of the first-ever Ruby Programming Challenge For Newbies.

Felipe Elias Philipp

Satish>> Welcome Felipe and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Felipe>> Thanks Satish for the opportunity. Well, about me… I’m a Brazilian guy, a web developer and a Mac user. I’m 22 years old and I started to program at school, since I was 16. Since then, programming has become my life and I can’t imagine myself doing any other thing.

Satish>> How did you get involved with Ruby programming?

Felipe>> I discovered Ruby through Rails on a well-known website by Brazilians: iMasters. I was just amazed as it was so easy to understand the Ruby code and I could solve the problems in a very simple way. This got me very motivated and I became more interested in the subject.

Continue reading “Felipe Elias Philipp Winner RPCFN #1 (Reprint)”

RPCFN: Shift Subtitle (#1) – Reprint

Ruby Programming Challenge For Newbies

RPCFN: Shift Subtitle (#1)

By Fabio Akita

Note: This article first appeared on 24th Sept. 2009 but the original is not accessible; hence the reprint.

After a very encouraging response to our poll from YOU, the readers of the RL blog, RL is happy to announce the first-ever fortnightly ( bi-weekly / every 14 days) “Ruby Programming Challenge For Newbies (RPCFN)” in Ruby. Thanks to YOU, the Ruby community, people like Fabio Akita and companies like Locaweb who make all of this possible.

About Fabio Akita

Fabio AkitaFabio Akita is a Brazilian Rails enthusiast, also known online as “AkitaOnRails”. He regularly write posts on his own blog and had published the very first book tailored for the Brazilian audience called “Repensando a Web com Rails”.

He is now a full-time Ruby on Rails developer working as Project Manager at Locaweb, Brazil. He’s also the creator of the “Rails Summit Latin America“, the largest international Rails event in South America.

Fabio has this to say about the challenge:

If you’re learning a new language such as Ruby, it is important that you practice it. And the best way to start is by scratching your own itch. Anything goes. It’s not unusual to start by writing simple command line scripts to help out your everyday routine. That’s why I thought of a very trivial exercise in the first challenge. It should demand that you know the basics for a variety of Ruby subjects such as regular expressions, file manipulation, time calculation and so on.

UK based Passenger Hosting
RPCFN
Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !
Winners
Update

Continue reading “RPCFN: Shift Subtitle (#1) – Reprint”

RPCFN: Ruby Programming Challenge For Newbies (Reprint)

RPCFN: Ruby Programming Challenge For Newbies

Note: This article first appeared on 20th Sept. 2009 but the original is not accessible; hence the reprint.

After a very encouraging response to our poll from YOU, the readers of the RL blog, RL is happy to announce the first-ever fortnightly (every 14 days) “Ruby Programming Challenge For Newbies (RPCFN)” that starts on Friday, 25th Sept. 2009.

What Is The RPCFN?

RPCFN

The RPCFN is a fortnightly (every 14 days) programming challenge for Ruby Newbies in the spirit of the Ruby Quiz. A new RPCFN will be posted on this RubyLearning blog every alternate Friday, starting 25th Sept. 2009. The contest is open to individuals only and you are invited to contribute solution(s) and/or discussion(s) as comments to the respective blog post. 13 days after the RPCFN is posted (i.e. on a Thursday), all the solutions will be thrown open for everyone to see and comment upon. The next day i.e. Friday, the cycle begins again. The Ruby working solution(s) should be clear-cut, follow Ruby conventions and still be easy to understand.

Continue reading “RPCFN: Ruby Programming Challenge For Newbies (Reprint)”

Poll: Ruby Problems for Beginners and Prizes (Reprint)

Note: This article first appeared on 13th Sept. 2009 but the original is not accessible; hence the reprint.

Poll: Ruby Problems for Beginners and Prizes

Many RubyLearning participants wrote in asking RubyLearning to start a weekly post containing a problem to be solved using Ruby. A problem will be posted here every week / fortnight and anyone is free to offer their solution (the solution should be clear-cut, follow Ruby conventions and still be easy to understand) as a comment to the blog post. A small panel will evaluate the solutions received and decide the best amongst them all. The person with the best solution will be awarded a token prize which could be a Peepcode or a Pragmatic screencast or something equivalent. Maybe some sponsors could chip in with some prizes!

RPCFN

RubyLearning is open to this idea and will start the same provided there is a good response to this. There’s a single question poll below which please answer and what’s more important is to post your thoughts, suggestions etc. as comments to this blog post.

We do have the Ruby Quiz, a weekly programming challenge for Ruby programmers. What’s also needed is something for programmers starting off with Ruby. Maybe RubyLearning could provide this.

We look forward to your response(s) and thoughts, suggestions (thoughts on the nature of the Ruby problem to be asked, evaluation criteria etc.

Continue reading “Poll: Ruby Problems for Beginners and Prizes (Reprint)”

RPCFN: Japanese Mosaic Problem (#14)

Ruby Programming Challenge For Newbies

RPCFN: Japanese Mosaic Problem (#14)

By Joseph Wilk

About Joseph Wilk

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.

Prizes

  • 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

RPCFN

The 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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

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.

Questions?

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.

The Participants

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

Previous Challenge

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.

Update

  • The (#15) challenge by Julio Javier Cicchelli, Netherlands is scheduled for Nov. 2010.

Technorati Tags: , , , ,

Programming Challenge for Newbies in Clojure and Python too?

Programming Challenge for Newbies in Clojure and Python too?

RubyLearning has been conducting the monthly Ruby Programming Challenge for Newbies for over a year now and so far 12 challenges have been completed. The 13th challenge is in progress. All this was possible due to the extensive support we got from Rubyists across the world. Also, you all indicated that we continue with these challenges in the months to come.

Recently, my colleague Dhananjay Nene posted a Python based solution to the 13th Ruby challenge. While discussing the solution it struck me that it would help Clojure and Python Newbies, if we opened up these challenges in these languages too. Dhananjay and some of my Clojure colleagues are interested in evaluating the submitted solutions in Clojure and Python and maybe we could start the challenges from Oct. 2010.

Clojure and Python enthusiasts – interested? What Do you Think? What is Your Opinion? Please share in the comments below.

Update

3rd Sept. Thanks for the very encouraging response. Based on the feedback received so far, we have decided the following:

  • We will start the challenges for Clojure, Python and Ruby from 1st Oct. 2010. We will call these “Programming Challenge for Newbies” and host it on this blog till end Dec. 2010. If the response is encouraging, we can host the challenges on different domains.
  • We will have separate panels to evaluate the solutions. One each for Clojure, Python and Ruby.
  • We will keep separate prizes for the 3 languages (and hopefully would find some sponsors).
  • The challenge problem setters (fixed till Dec. 2010) would be told that the problem should be solvable in all languages and specifically Clojure, Python and Ruby. This means that the problem setter should not set a problem that needs to be solved by some specific language feature.

Technorati Tags: , , , , ,

RPCFN: Economics 101 (#13)

Ruby Programming Challenge For Newbies

RPCFN: Economics 101 (#13)

By Dr. Bruce Scharlau

About Dr. Bruce Scharlau

Dr. Bruce Scharlau In Dr. Bruce’s own words: “I’ve been using and teaching Ruby since trying out the cookbook example in the summer of 2006. As soon as I saw how much easier it all was with Ruby and Rails, I was hooked. I now try to do as much with Ruby as I can with my teaching and own work. It’s a joy to code with Ruby compared to using other languages, which don’t seem as intuitive by comparison. When I’m not busy working, then I try to spend time with the family, or get out sailing.”

Dr. Bruce has this to say about the challenge:

The challenge is useful for newbies as a way to extend their skills in a useful manner. They will learn how they solved the problem, and also gain from seeing how others solved the problem too. We all start from different places when we solve problems, so the ‘obvious’ solution to you, might not occur to someone else who has a different experience of Ruby. This is why it’s good to share examples and code together when possible too.

Prizes

  • 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

RPCFN

The Challenge

As a developer it helps to be able to understand a client’s perspective and to build suitable applications to help them in their field. This means knowing a bit about the world. We’ll help this background knowledge by doing looking at some economic data, and also testing our XML parsing skills.

The file cia-1996.xml is the data from the CIA World Factbook of 1996 in XML format. It has details about 260 countries across five continents. Your challenge, should you choose to accept it, is to uncover the following details buried within this file:

  1. What is the population of the country with the most people? Yes, we know it’s China, but just how many people lived there in 1996?
  2. What are the five countries with the highest inflation rates, and what were those rates in 1996?
  3. What are the six continents in the file and which countries belong to which continent? Can you also produce them in alphabetical order?

Once you’ve worked out how to do part (2), then you can do anything with this file; all you need is a bit of time. Knowing how to do (2) you could then do (3) without too much effort.

You can use any XML library. I used REXML as it’s already there if you have Ruby installed; so don’t need to worry about any gem installs. You may also want to look at how REXML uses XPath.

Submit your solution of your code, which includes a test file that answers the three questions.

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 27th Sept. 2010 (Indian Standard Time). No new solutions will be accepted from 28th Sept. onwards.
  • On 28th Sept. 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 30th Sept. 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • Dr. Bruce Scharlau.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team.

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Dmytrii Nagirniak, Australia
  2. Kirill Shchepelin, Russia
  3. Lukasz Hanuszczak, Poland
  4. Rick DeNatale, USA
  5. David Lake, England
  6. Julio C. Villasante, Cuba
  7. Dan Wanek, USA
  8. Matthew Dahl, USA

Just for Fun

  1. Casimir Saternos, USA
  2. Paul McKibbin, U.K.

Previous Challenge

RPCFN: Cycle Tracks (#12) by David Griffiths.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • The (#14) challenge by Joseph Wilk, U.K. is scheduled for Oct. 2010.

Technorati Tags: , , , , ,

Do YOU want us to continue with the Ruby Challenge for Newbies?

Do YOU want us to continue with the Ruby Challenge for Newbies?

RubyLearning has been conducting the monthly Ruby Programming Challenge for Newbies for over a year now and so far 11 challenges have been completed. The 12th Challenge is in progress. All this was possible due to the extensive support we got from Rubyists across the world.

However today, probably due to lack of time or other commitments, not many experienced Rubyists are willing to set a Ruby challenge for the newbies? So, what do we do with the newer challenges? Do we dis-continue with the challenges? Do we change it from monthly to as an when? What are your suggestions?

Newbies, do you find the challenge interesting and useful – what are your thoughts?

In the meantime, are you interested in setting a Ruby challenge for the newbies? If so, do email me at satishtalim [at] gmail.com.

Do post your thoughts and suggestions. I am hopeful that we would be able to continue with the challenges.

Update

11th Aug. Based on the feedback received, I have decided to continue with the Ruby Challenges. However, these challenges may not be monthly but as and when. It’s now up to the Ruby community to help me out with setting the challenges. Let’s do it!

Technorati Tags: , , ,

RPCFN: Cycle Tracks (#12)

Ruby Programming Challenge For Newbies

RPCFN: Cycle Tracks (#12)

By David Griffiths

Today, we complete one year of Ruby Programming Challenge for Newbies. RubyLearning is grateful to all the Ruby experts and participants who have actively helped make these challenges interesting and popular.

About David Griffiths

David Griffiths In David’s own words: “I’m an agile developer, writer and trainer based in the UK. I used to write a monthly Java development column and I’ve used and taught agile methods to companies around the UK. But I’ve been writing code since I was 12 years old. I worked with Java from the alpha release in the 90s. A lot of things on the client side as well as a lot of enterprise stuff. But everything changed for me when I got an early copy of Bruce Tate’s Up and Running with Ruby on Rails. I found myself in Boston for 3 days with nothing else to do. And anyone who’s been to Boston knows that it’s famous for two things: coffee and book shops. So I got a copy of Tate’s book and a laptop and spent three days burying myself deep into Rails and consuming more caffeine than was probably wise. It was incredible. Here was a way of doing things with a few simple commands, that would have taken 19 classes, an enterprise container and 3-400 lines of XML in Java. An old professor once told me “The profound is always simple” – and Rails was the living embodiment of that. I was hooked. It really hasn’t been the same since.”

Prizes

  • 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

RPCFN

The Challenge

The entire challenge details are available here.

Ensure that you submit both the solutions – see pages 2 and 3.

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 29th Aug. 2010 (Indian Standard Time). No new solutions will be accepted from 30th Aug. onwards.
  • On 30th Aug. 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 5th Sept. 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • David Griffiths.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team.

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Alex Chateau, Latvia
  2. Kirill Shchepelin, Russia
  3. Sebastian Rabuini, Argentina
  4. Santosh Wadghule, India
  5. Juan Gomez, USA
  6. Julio C. Villasante, Cuba
  7. Paul McKibbin, UK
  8. Viktor Nemes, Hungary

Just for Fun

  1. Dmytrii Nagirniak, Australia
  2. Benoit Daloze, Belgium
  3. Cary Swoveland, Canada

The Winners

Winners

Congratulations to the winners of this Ruby Challenge. They are:

Previous Challenge

RPCFN: The Game of Life (#11) by Elise Huard.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • This challenge is now closed.
  • The (#13) challenge by Bruce Scharlau, U.K. is scheduled for Sept. 2010.

Technorati Tags: , , , , ,

Dmitry Lipovoi Winner RPCFN #10

In this brief interview, Satish Talim of RubyLearning talks to Dmitry Lipovoi of Russia, winner of the tenth Ruby Programming Challenge For Newbies.

Dmitry Lipovoi

Satish>> Welcome Dmitry and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Dmitry>> Hey. My name is Dmitry, and I’ve been programming since I was 14 years old, when I made my first “Hello World” in Pascal work. I’m absolutely sure that programming should be fun if you’re not doing something wrong :)

Satish>> How did you get involved with Ruby programming?

Dmitry>> About one and a half years back I discovered Ryan Bates’ RailsCasts. It was really inspiring, so I started to look at how these things work. That was my first Ruby experience.

Then I read a few articles on TDD/BDD in Ruby and that was the point of no return. It was so easy and natural in comparison with my Java experience that I haven’t stopped playing with it since then.

Satish>> Could you name three features of Ruby that you like the most, as compared to other languages? Why?

Dmitry>>

  1. I like Ruby for its pure object oriented approach. I mean, for example Java and many other mainstream languages are more “class oriented”. They have classes as something special, as their main idea. But Ruby is different. Object is the center of the universe in Ruby and not class. And it’s really great.
  2. Blocks. Definitely one of the most useful things in Ruby. Maybe it’s not a unique feature, but it really rocks!
  3. Although it’s not a plain feature of the language, I very much like Ruby’s approach to testing. The Ruby community is considered as the “most testing community” and I like that. Testing makes it easy to dig into a new project when you try to understand how things work, how they should be used. And almost any open source Ruby project has a good test suite.

Satish>> How was experience of taking part in the Ruby Programming Challenge For Newbies (RPCFN)?

Dmitry>> It reminds me of the good old days when I participated in ICPC. Quite fun.

Actually not so many challenges judge your code. And I’m glad to see that for RPCFN code beauty is important.

Also it was nice to discover other solutions and see the different approaches to the problem. Some of them are really worth looking into.

Satish>> You are based in Russia. How is the Ruby and Rails scenario there?

Dmitry>> Unfortunately Ruby isn’t much popular here.

Nevertheless the community is growing little by little and I can see that a couple of projects, here and there, use Ruby. But it’s still nothing in comparison with PHP or Java.

Satish>> What are your future plans?

Dmitry>> In the near future I’d like to move from Java to Ruby completely; dig deeper into the Rails 3 source and participate in other open source Ruby projects.

Also, I’m going to participate in Gregory Brown’s Ruby Mendicant University this autumn. And I would like to thank him for such an opportunity.

Thank you Dmitry. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Dmitry would be glad to answer.

Technorati Tags: , , , , ,

RPCFN: The Game of Life (#11)

Ruby Programming Challenge For Newbies

RPCFN: The Game of Life (#11)

By Elise Huard

About Elise Huard

Elise HuardElise Huard is based in Brussels, Belgium and is the owner of Jabberwocky, a solutions company mostly focused on Rails. She has worked with a few other technologies before falling in love with Rails and Ruby about 3 years ago and going freelance to work with Ruby full time. She contributes to open source projects as much as she can, and has given talks at a few Ruby and Rails conferences. She’s a jack of all trades, loves reading, tinkering, food, travel, learning, and people out of the ordinary.

Elise has this to say about the challenge:

This challenge consists in implementing the game of life. This is a problem that is simple to understand, but requires some thought to implement correctly. Tests will help you spot your own reasoning fallacies. And of course, every hacker has to have implemented the game of life at least once :)

Our Awesome Sponsor

This monthly programming challenge is sponsored by Backup My App.

Backup My App

Backup My App is an automatic backup service for Ruby on Rails applications. You simply install the plugin to your Rails application and they handle the rest of the process. They store backup history for several weeks and you can restore any of them automatically. Try out their 1 GB plan for free. Backup My App has sponsored this challenge and is proud to make this contribution to the Ruby community.

Prizes

  • 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 and a free 10 GB account for a year from Backup My App.
  • 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.
  • All the participants in this challenge (except the participant with the best Ruby solution) will get a free 5 GB account for 6 months from Backup My App.

The four persons who win, can’t win again in the next immediate challenge but can still participate.

The Ruby Challenge

RPCFN

The Challenge

The entire challenge details are available at: http://github.com/elisehuard/game_of_life

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 2nd Aug. 2010 (Indian Standard Time). No new solutions will be accepted from 3rd Aug. onwards.
  • On 3rd Aug. 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 10th Aug. 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • Elise Huard.
  • Sponsors Backup My App.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team.

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Dominik Masur, Germany
  2. Sergey Kruk, Russian Federation
  3. Mark Mba Wright, USA
  4. Andrew Cox, U.K.
  5. Julio C. Villasante, Cuba
  6. Nils Riedemann, USA
  7. Valério Farias, Brazil
  8. Christopher Fortenberry, USA
  9. Falk Pauser, Germany
  10. Sam Johnson, Australia
  11. Brad O’Connor, Australia

Just for Fun

  1. Trevor Fountain, U.K.
  2. William Crawford, USA

Previous Challenge

RPCFN: Business Hours (#10) by Ryan Bates.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • The (#12) challenge by David Griffiths, USA is scheduled for Aug. 2010.

Technorati Tags: , , , , ,

Benoit Daloze Winner RPCFN #9

In this brief interview, Satish Talim of RubyLearning talks to Benoit Daloze of Belgium, winner of the ninth Ruby Programming Challenge For Newbies.

Benoit Daloze

Satish>> Welcome Benoit and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Benoit>> I would first like to thank RubyLearning for all they have done. I am a 19 year old student in first bachelor in computer sciences (at UCL, Louvain-la-Neuve). I am studying Java at courses, but I think I did more Ruby this year. Well, I just can not stop thinking “This would be so much better in Ruby”.

Satish>> How did you get involved with Ruby programming?

Benoit>> I have been looking on Ruby for some years now. I met Ruby the first time as a scripting language in a game software when I was 15, and since then always wanted to know more about it. It took me some time to learn it, because I did not find the good resources. I feel I am getting more and more involved everyday, as does my knowledge of Ruby.

Satish>> Could you name three features of Ruby that you like the most, as compared to other languages? Why?

Benoit>>

  1. Metaprogramming: This introduces a great way to program, and allows you to make it even shorter. It gives me the feeling that I really have a control on the objects, because you can so easily manipulate them.
  2. Flexibility: Whenever you think you can mix some concepts together in Ruby, it just works, limitations are rare, and often out of imagination’s bounds. You are pretty much doing it the way you want, and Ruby lets you code that way.
  3. Blocks: Blocks is a entire way of expression, and the amount of complex methods made simple by this is awesome. Just think how you would do a #group_by, #each_slice or #partition in other languages. Most of the time it would be far more verbose and you would likely get a headache. Ruby has brought all the many useful things in the core, because it can be expressed in a simple method.

Satish>> How was experience of taking part in the Ruby Programming Challenge For Newbies (RPCFN)?

Benoit>> I’m participating since the fourth challenge, and I’m happy to participate in these interesting challenges. It is also a great way to discover other’s code, often very imaginative and original. And coding always makes you better in the language, so it is all for the best!

Satish>> You are based in Belgium. How is the Ruby and Rails scenario there?

Benoit>> People have now started noticing Rails, but this activity is mainly driven by some specific companies. Ruby is somehow not known, and sadly ignored in universities. ( But I’m trying to remedy that :) )

Satish>> What are your future plans?

Benoit>> I am going to work on Rails this summer, to discover this part of Ruby I have not used much yet. I’m also doing some Ruby everyday, for my own use, just feeling happy to code with a beautiful language.

Thank you Benoit. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Benoit would be glad to answer.

Technorati Tags: , , , , ,

RPCFN: Business Hours (#10)

Ruby Programming Challenge For Newbies

RPCFN: Business Hours (#10)

By Ryan Bates

About Ryan Bates

Ryan BatesRyan Bates has been involved in web development since 1998. In 2005 he started working professionally with Ruby and Rails and is now best known for his work on Railscasts, the free Ruby on Rails screencast series.

Ryan has this to say about the challenge:

Sometimes when working in a structured framework environment such as Rails it is easy to forget about the fundamentals of Ruby and how to organize code. The majority of this challenge could be done in one large method, but I encourage you to focus on readability through refactoring. This challenge also exercises working with times and iterations.

Our Awesome Sponsor

This monthly programming challenge is sponsored by Backup My App.

Backup My App

Backup My App is an automatic backup service for Ruby on Rails applications. You simply install the plugin to your Rails application and they handle the rest of the process. They store backup history for several weeks and you can restore any of them automatically. Try out their 1 GB plan for free. Backup My App has sponsored this challenge and is proud to make this contribution to the Ruby community.

Prizes

  • 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 and a free 10 GB account for a year from Backup My App.
  • 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.
  • All the participants in this challenge (except the participant with the best Ruby solution) will get a free 5 GB account for 6 months from Backup My App.

The four persons who win, can’t win again in the next immediate challenge but can still participate.

The Ruby Challenge

RPCFN

The Challenge

Chunky Bacon Begone is a dry-cleaning company known for its speedy service. It guarantees to dry-clean anything within two business hours or less. The problem is, when the customer drops off the clothes, he needs to know what time they are guaranteed to be done.

It is your job to write a Ruby script which will determine the guaranteed time given a business hour schedule. You must create a class called BusinessHours which allows one to define the opening and closing time for each day. It should provide the following interface:

hours = BusinessHours.new("9:00 AM", "3:00 PM")
hours.update :fri, "10:00 AM", "5:00 PM"
hours.update "Dec 24, 2010", "8:00 AM", "1:00 PM"
hours.closed :sun, :wed, "Dec 25, 2010"

The update method should change the opening and closing time for a given day. The closed method should specify which days the shop is not open. Notice days can either be a symbol for week days or a string for specific dates. Any given day can only have one opening time and one closing time — there are no off-hours in the middle of the day.

A method called calculate_deadline should determine the resulting business time given a time interval (in seconds) along with a starting time (as a string). The returned object should be an instance of Time. Here are some examples:

hours.calculate_deadline(2*60*60, "Jun 7, 2010 9:10 AM") # => Mon Jun 07 11:10:00 2010
hours.calculate_deadline(15*60, "Jun 8, 2010 2:48 PM") # => Thu Jun 10 09:03:00 2010
hours.calculate_deadline(7*60*60, "Dec 24, 2010 6:45 AM") # => Mon Dec 27 11:00:00 2010

In the first example the time interval is 2 hours (7,200 seconds). Since the 2 hours fall within business hours the day does not change and the interval is simply added to the starting time.

In the second line an interval of 15 minutes (900 seconds) is used. The starting time is 12 minutes before closing time which leaves 3 minutes remaining to be added to the next business day. The next day is Wednesday and therefore closed, so the resulting time is 3 minutes after opening on the following day.

The last example is 7 hours (25200 seconds) which starts before opening on Dec 24th. There are only 5 business hours on Dec 24th which leaves 2 hours remaining for the next business day. The next two days are closed (Dec 25th and Sunday) therefore the deadline is not until 2 hours after opening on Dec 27th.

Tip: Use Time.parse to generate a Time from a string. You may need to require “time” in order to do this.

Requirements: This has to be a pure Ruby script, using only the Ruby Standard Libraries (meaning, no external Gems, libraries). You do not need to build a gem for this. Pure Ruby code is all that is needed. Ryan will mostly be judging by the beauty of your code as long as it satisfies his test case.

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 27th June 2010 (Indian Standard Time). No new solutions will be accepted from 28th June onwards.
  • On 28th June 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 30th June 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • Ryan Bates.
  • Sponsors Backup My App.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team.

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Simon Menke, Belgium
  2. Colin Casey, Canada
  3. Stephane Tang, France
  4. Juan Villanelo, Chile
  5. Vasko Zdravevski, USA
  6. Sebastián Rabuini, Argentina
  7. Dmitry Lipovoi, Russia
  8. Andy Vanasse, USA
  9. Cary Swoveland, Canada
  10. Jeremy Peterson, USA
  11. Paul Mucur, UK
  12. Delbert Mitten, USA
  13. Theo Mills, USA
  14. Rémy Coutable, France
  15. James Silberbauer, South Africa
  16. Michael Cramm, Canada
  17. Christopher Fortenberry, USA
  18. Tanzeeb Khalili, Canada

Just for Fun

  1. James Edward Gray II, USA
  2. Eric Hutzelman, USA
  3. Benoit Daloze, Belgium

The Winners

Winners

Congratulations to the winners of this Ruby Challenge. They are:

Previous Challenge

RPCFN: Interactive Fiction (#9) by Avdi Grimm.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • This challenge is now closed.
  • All the solutions have been tested and the results are available here.
  • The (#11) challenge by Elise Huard, Belgium is scheduled for 1st July 2010.

Technorati Tags: , , , , ,

Paul Barry Winner RPCFN #8

In this brief interview, Satish Talim of RubyLearning talks to Paul Barry of USA, winner of the eighth Ruby Programming Challenge For Newbies.

Paul Barry

Satish>> Welcome Paul and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Paul>> Sure, I’m a Web Developer from Baltimore, MD. I’ve been doing web development for over 10 years in a variety of languages and frameworks including Perl, PHP, Java and Ruby.

Satish>> How did you get involved with Ruby programming?

Paul>> I got started with Ruby programming the same way I suspect many other Ruby developers did, which is through Rails. At the time Rails hit the scene, I was pretty entrenched as a Java developer. My initial reaction to Rails was that it seemed to have a lot of good ideas in it, but I figured we could find a way to implement those idea in Java. The more I dug into Rails, the more I realized that it was the Ruby language that made the clear, powerful abstractions that make up Rails possible and that I could use Ruby to create useful abstractions in my own code as well.

Satish>> Could you name three features of Ruby that you like the most, as compared to other languages? Why?

Paul>>

  1. Blocks: The best thing about blocks is that when you first start using Ruby, Ruby’s block syntax gets you to start using anonymous functions and higher-order functions all over the place in your code without even realizing it.
  2. Everything is an object: This is makes some aspects of the language simple to understand in that everything follows a few simple rules. String, Integers, Regexs, and most importantly Classes, are all just objects, just data, that you can manipulate at runtime.
  3. Class definitions: These are just expressions that are evaluated at runtime, expressions that have access to the class that is being defined. This allows you to create methods that when called will generate other methods, such as has_many in Rails.

When you put these three features together, you have a metaprogramming environment that I would argue is as powerful as what Lisp macros give you, although I’m sure there are some hardcore Lisp programmers out there that would disagree with me.

Satish>> How was experience of taking part in the Ruby Programming Challenge For Newbies (RPCFN)?

Paul>> I’ve really enjoyed it. It’s a great exercise to come up with a solution to a problem and then be able to compare your solution to what other developers came up with. Most of the challenges so far have been just the right size, which is hard enough to make you think about it, but short enough to where you can work out an interesting solution without having to invest too much time in it.

Satish>> You are based in Baltimore, USA. How is the Ruby and Rails scenario there?

Paul>> Baltimore has a great Ruby and Rails community. Of course, RailsConf is coming to town, which we’re all excited about. Many of us that are part of the B’More on Rails group, are working on various initiatives to make sure everyone has a great time at RailsConf. The Baltimore Ruby on Rails group has a bunch of smart people that meet regularly at various events. We’re always trying to do everything we can to help new people become part of the community as well. There’s also a lot of overlap with the DC/Northern Virginia communities which are close by and very good as well.

Satish>> What are your future plans?

Paul>> I’m going to Disneyland!

Just kidding. There is so much stuff I want to learn more about, it’s hard to find time for all of it. I really like where Rails is going with Rails 3. As much as I love Ruby, I’m also interested in other languages as well, especially functional ones like OCaml, Erlang, Clojure, Scala and Haskell. I think asynchronous IO/evented frameworks like Node.js and EventMachine provide a better model for building network servers. Technologies like XMPP and the WebSocket API that’s part of HTML5 are also going to be key in the next generation of real-time, connected web and mobile applications.

Thank you Paul. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Paul would be glad to answer.

Technorati Tags: , , , , ,

RPCFN: Interactive Fiction (#9)

Ruby Programming Challenge For Newbies

RPCFN: Interactive Fiction (#9)

By Avdi Grimm

About Avdi Grimm

Avdi GrimmAvdi Grimm is a husband, father, software cultivator living in southern Pennsylvania, USA. He has been been working with the Ruby language for almost ten years, and is still finding new reasons to love it. He is the author of NullDB, Hammertime, AlterEgo, HookR and numerous other Rubygems and has contributed code to Gemcutter, UtilityBelt, the DataMapper/SimpleDB adapter, and other projects. He writes about Ruby and software development at his blog Virtuous Code.

Avdi has this to say about the challenge:

One of the hardest parts of getting started with a new programming language is picking problems to practice on. The problems need to be difficult enough to give you an opportunity to apply the features of the language, but small enough to complete in a reasonable amount of time. RPCFN is a great way to find practice problems which have been scoped to that “just right” size by experienced Rubyists. Complete these challenges and you will be sure to gain confidence and proficiency in the Ruby language.

Our Awesome Sponsors

This monthly programming challenge is co-sponsored by ELC Technologies and Backup My App.

A leading software development firm based in Santa Barbara, California

Founded in 1991, ELC Technologies delivers the value of next-generation Web technologies to today’s businesses, harnessing the power of mobile applications, cloud computing, and software as a service (SaaS). ELC Technologies’ leadership in agile software development processes has brought success to business-critical implementations for clients ranging from Cisco to Tribune Interactive to LiveNation. The company is a worldwide leader in Ruby on Rails development and has pioneered dynamic language development across multiple platforms. Short iterations, demos early and often, and constant client communication regarding vision and progress are all part of the ELC promise and what makes them such a valuable development partner for Global 2000 companies.

ELC Technologies is headquartered in Santa Barbara, California.

Backup My App

Backup My App is an automatic backup service for Ruby on Rails applications. You simply install the plugin to your Rails application and they handle the rest of the process. They store backup history for several weeks and you can restore any of them automatically. Try out their 1 GB plan for free. Backup My App has co-sponsored this challenge and is proud to make this contribution to the Ruby community.

Prizes

  • 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 and a free 10 GB account for a year from Backup My App.
  • 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.
  • All the participants in this challenge (except the participant with the best Ruby solution) will get a free 5 GB account for 6 months from Backup My App.

The four persons who win, can’t win again in the next immediate challenge but can still participate.

The Ruby Challenge

RPCFN

The Challenge

The entire challenge details are available at: http://github.com/avdi/rpcfn-interactive-fiction.

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 24th May 2010 (Indian Standard Time). No new solutions will be accepted from 25th May onwards.
  • On 25th May 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 30th May 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • Avdi Grimm.
  • Sponsors ELC Technologies and Backup My App.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team.

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Aldric Giacomoni, USA
  2. Benoit Daloze, Belgium
  3. James Martin, Australia

Just for Fun

  1. Tanzeeb Khalili, Canada
  2. Vojto Rinik, Slovakia

The Winners

Winners

Congratulations to the winners of this Ruby Challenge. They are:

Previous Challenge

RPCFN: XML Transformer (#8) by Jamie van Dyke.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • This challenge is now closed.
  • The (#10) challenge by Ryan Bates, USA is scheduled for 1st June 2010.

Technorati Tags: , , , , ,

RPCFN: XML Transformer (#8)

Ruby Programming Challenge For Newbies

RPCFN: XML Transformer (#8)

By Jamie van Dyke

About Jamie van Dyke

Jamie van DykeJamie van Dyke has been using Ruby and Rails since the beginning of 2005, has contributed significantly to the Rails documentation and code base, as well as running his own Rails business and being responsible for building Engine Yard’s European support team. Jamie is now the CTO over at Boxedup.

Jamie has this to say about the challenge:

This challenge is ideal for both beginner and advanced users. You can solve it in multiple ways and with differing levels of complexity, each level giving more flexibility. I hope you enjoy trying to solve the challenge and I look forward to seeing the results.

Our Awesome Sponsors

This monthly programming challenge is co-sponsored by Eden Development and Backup My App.

A leading software development firm based in Winchester, UK

Eden Development is a leading software development firm based in Winchester, UK, specialising in Ruby applications. They craft dependable, flexible and beautifully made software which meets real business needs. They stand for quality, integrity, real craftsmanship and peace of mind for their customers. They also teach basic Ruby to Agile/XP courses: they love learning themselves and are delighted to support the RubyLearning initiative.

Backup My App

Backup My App is an automatic backup service for Ruby on Rails applications. You simply install the plugin to your Rails application and they handle the rest of the process. They store backup history for several weeks and you can restore any of them automatically. Try out their 1 GB plan for free. Backup My App has co-sponsored this challenge and is proud to make this contribution to the Ruby community.

Prizes

  • 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 and a free 10 GB account for a year from Backup My App.
  • 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.
  • All the participants in this challenge (except the participant with the best Ruby solution) will get a free 5 GB account for 6 months from Backup My App.

The four persons who win, can’t win again in the next immediate challenge but can still participate.

The Ruby Challenge

RPCFN

The Challenge

Introduction

I love a good challenge and find it helps you discover different aspects of a language, and also different methods to achieve the same goal. Seeing how others completed a quiz also helps you to expand your knowledge and experience which will give you more insight in the future.

The best tests are always ones based on real world examples. I’ve tried to simplify this one so it’s accessible to all that want to take a stab, while at the same time allowing those that one to be more advanced the opportunity to show off a little. You could complete this with a simple solution, or spend more time and give an elegant, more ruby-ish answer. You choose.

A library I recently wrote had to import data on a regular basis. I needed to normalise the data before I could import it because the data was from different XML feeds, but in unknown formats. So, your challenge is to build an XML transformer that can take any (within reason) XML file and change it into an expected XML format.

Specifics

You can download 3 source XML files as examples. You need to work out how to convert each of these files in to the expected output, bearing in mind that these are merely examples and therefore you should make your transformer as flexible as possible to handle other source inputs.

You will need to employ the use of an XML library, personally I use the nokogiri rubygem, but feel free to choose your own. Once you’ve decided on XML parser it’s up to you how you go about solving this quiz. I’ve designed this quiz to give you the freedom to solve this however you see fit, the only stipulation is that you stick to Ruby!

Additional Information

Qs. Do we have to use an XML parser?

Ans. Well, no, but it will probably be easier if you do.

Qs. Is it okay to assume that the source file has only first names and last names? It has no other data, e.g. ages, sexes, … ?

Ans. In this example there are only 2 fields that you need to worry about. Bonus points go to the results that can handle multiple formats with multiple fields. Of course, any file that has 3 fields in the source, should be outputting 3 fields in the result.

Qs. Is it necessary to indent output data (result xml)?

Ans. The results may ignore whitespace outside of elements but not inside.

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:

  1. Your name:
  2. Country of Residence:
  3. GIST URL of your Solution (i.e. Ruby code) with explanation and / or test cases:
  4. Code works with Ruby 1.8 / 1.9 / Both:
  5. Email address (will not be published):
  6. Brief description of what you do (will not be published):

Note:

  • 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 26th Apr. 2010 (Indian Standard Time). No new solutions will be accepted from 27th Apr. onwards.
  • On 27th Apr. 2010 all the solutions will be thrown open for everyone to see and comment upon.
  • The winning entries will be announced on this blog before 30th Apr. 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:

Donations

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.

Click here to lend your support to: Support RubyLearning With Some Love and make a donation at www.pledgie.com !

Acknowledgements

Special thanks to:

  • Jamie van Dyke.
  • Sponsors Eden Development and Backup My App.
  • GitHub, for giving us access to a private repository on GitHub to store all the submitted solutions.
  • The RubyLearning team, namely Satoshi Asakawa (Japan) and Victor Goff III (USA).

Questions?

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.

The Participants

There are two categories of participants. Some are vying for the prizes and some are participating for the fun of it.

In the competition

  1. Richard Colley, Australia
  2. Paul Barry, USA – declared winner (best solution)
  3. John Prince, USA – declared winner (randomly selected)
  4. Tanzeeb Khalili, Canada – declared winner (randomly selected)
  5. Rémy Coutable, France
  6. Adam Lum, USA – declared winner (randomly selected)
  7. Vijay Thiruvallur, India
  8. Benoit Daloze, Belgium

Just for Fun

The Winners

Winners

Congratulations to the winners of this Ruby Challenge. They are:

Previous Challenge

RPCFN: Broadsides (#7) by James Edward Gray II.

Note: All the previous challenges, sponsors and winners can be seen on the Ruby Programming Challenge for Newbies page.

Update

  • This challenge is now closed.
  • The (#9) challenge by Avdi Grimm, USA is scheduled for 1st May 2010.

Technorati Tags: , , , , ,

Dmitriy Nagirnyak Winner RPCFN #7

In this brief interview, Satish Talim of RubyLearning talks to Dmitriy Nagirnyak of Australia, winner of the seventh Ruby Programming Challenge For Newbies.

Dmitriy Nagirnyak

Satish>> Welcome Dmitriy and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Dmitriy>> First of all I want to say Thanks for the opportunity that RubyLearning gives to people. Personally, saying Thanks to Satish who drives the site with passion. My name is Dmitriy (Dmytrii or just Dima), 27 years old guy who is a Software Engineer by profession and in heart. I made my first steps in IT when I was about 14 years old and since those days it has become my passion. Sometimes I write things in my blog. I love to spend time with people (and have some beer!), play basketball and enjoy driving a car. Currently living in Melbourne, though originally came from Ukraine.

Satish>> How did you get involved with Ruby programming?

Dmitriy>> Most of my professional career I have been a Windows, C# / .NET developer and, must admit: sometimes had feelings of love and hate about it. Though, being working for too long with mostly one language, it made sense for me to give a try to something new (I mean it – NEW – not just Java or another kind of same-style language) and give myself an “educational push”. After reading about different languages and platforms I decided that I just must go with Linux+Ruby. Ruby is one of not so many languages that I really “felt” and greatly sympathized to.

Satish>> Could you name three features of Ruby that you like the most, as compared to other languages? Why?

Dmitriy>> This is a bit tough question, but If I could name those they would probably be:

  1. Metaprogramming – this allows to build great custom DSLs (Shoulda, ActiveRecord, RSpec etc etc).
  2. Prototype-based programming – this just switches the way you think when comparing to more mainstream languages (C#, Java). It allows to do things in so much easier and better way.
  3. Lambdas/Blocks – needles to say that this feature is probably most commonly used in Ruby community which also simplifies the code very heavily. Even though Python has similar idiom, it is not the same at all and lambdas/blocks are considered to be one of unique Ruby features.

Satish>> How was experience of taking part in the Ruby Programming Challenge For Newbies (RPCFN)?

Dmitriy>> The broadsides challenge was very unusual in the way it had to be judged: Truth is in the machine. We had to write bots that would fight against each other. Apart from number of things I have learned (working with Enumerables, Arrays, Strings etc) there was an additional requirement set: understanding unknown opponents. So I had to figure out the solution that would work as “the best average”. So the work done for this challenge was very exciting as the challenge itself.

Satish>> How is the Ruby and Rails scenario in your country Australia?

Dmitriy>> It doesn’t feel that Ruby is hitting mainstream yet, but definitely there is more and more interest in it. There are number of great people who drive the community. A lot of them can be found in Ruby On Rails Oceania group. One of the companies here in Melbourne (and Sydney too) that uses Ruby stack of technologies is ThoughtWorks and they really seem to have bright guys in there. But generally I feel like the more Agile-ish a company is the more it is interested in Ruby.

Satish>> What are your future plans?

Dmitriy>> Currently I am resigning from my job and planing to change my career to go alongside with Ruby and step away slowly from C# (so I’m open to job offers :) ).
It will be a hard and risky life decision. But I feel like I am ready to take such a challenge. Hope it will work out well for me.

Thank you Dmitriy. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Dmitriy would be glad to answer.

Technorati Tags: , , , , ,

Guillaume Petit Winner RPCFN #6

In this brief interview, Satish Talim of RubyLearning talks to Guillaume Petit of France, winner of the sixth Ruby Programming Challenge For Newbies.

Guillaume Petit

Satish>> Welcome Guillaume and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?

Guillaume>> Thanks Satish for the opportunity. My name is Guillaume Petit a 26 year old nomad who sets off on a journey in the world of programming languages and has not come back yet! Aside from this, my main hobbies are reading manga, watching movies ( I am especially looking for great quotes ) or just stumbling on the Internet!

Satish>> How did you get involved with Ruby programming?

Guillaume>> It started about two years back when I discovered Ruby on Rails. I was more curious about this framework than Ruby itself at first (which I did not know), but I quickly got hooked by the language. Since then, I have been using Ruby for daily scripts here and there and continue to play with it.

Satish>> Could you name three features of Ruby that you like the most, as compared to other languages? Why?

Guillaume>> Ok, the first feature I really enjoy are blocks. Blocks offer a very powerful, yet easy way to deal with loops, iterations and nameless functions. It’s almost natural. What is really interesting is that when I started using blocks, I did not really understand the mechanism beneath, but yet, I was able to make good use of them.

Then I would go for the elegance and agility of the syntax. It’s an important point for me, a language needs to be pleasant when it comes to writing code, and in Ruby, it’s just a breeze.

The last point is more a way of doing things that a plain feature, I think. I am talking about testing. Ruby makes it really easy to test your code, and the Ruby community has largely adopted this practice. Using Ruby really made me aware of the importance of using tests, which I never did before with other languages that I used; so let’s call it a feature for today.

Satish>> How was experience of taking part in the Ruby Programming Challenge For Newbies (RPCFN)?

Guillaume>> It was fun. I like those challenges because they make you think and use the language in a way you may not be familiar with. While resolving the problem, you learn more about the language. It’s a very efficient way to progress.

Satish>> How is the Ruby and Rails scenario in your country France?

Guillaume>> It’s not quite as popular as I would like it to be, but it’s making its way in.

Satish>> What are your future plans?

Guillaume>> You really hit the spot with this question since I am actually looking for the answer myself. I guess I will have to win the next challenge, this will give me some more time to answer! ;-)

More seriously, I am actually working on a Rails application to create and manage web surveys, and maybe I will do an iPhone version of it!

See you on the next challenge !

Thank you Guillaume. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Guillaume would be glad to answer.

Technorati Tags: , , , , ,