Very simple programming exercises

  • Thread starter Lakshmanan Muthukrishnan
  • Start date
L

Lakshmanan Muthukrishnan

Hi,

I am reading ruby from the book "Programming ruby" and that book lacks
programming exercises. I want to work out some problems in ruby.

Please point me towards a good resource on the net or it can be a book
also.

thanks
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

On Sun, Jun 6, 2010 at 11:48 PM, Lakshmanan Muthukrishnan <
Hi,

I am reading ruby from the book "Programming ruby" and that book lacks
programming exercises. I want to work out some problems in ruby.

Please point me towards a good resource on the net or it can be a book
also.

thanks
Codingbat.com has lots of simple easy problems, but it's mostly Java and a
little bit of Python. Still, you can solve the problem however you like, you
just won't be able to use their automatic tester.

There are also a bunch at spoj.pl but I found that site frustrating, because
it's too dependent on string format of your output (a stray newline will
invalidate your solution, but you aren't given enough feedback to figure out
what formatting needs to change) And their time constraints are aimed at
compiled languages, which frequently prevents Ruby from being a possibility.

codechef.com is basically spoj.pl taken to the next level with a community
and flashy design. But I have had a lot of trouble getting their Ruby to
work right for me, and they don't keep track of which solutions you've
previously solved, so you can't really make a goal of solving all the
problems they have. I'll probably try it again in 6 months or so, see if
they've made that stuff better.

If you like math, projecteuler.net is a good choice, math problems whose
scope is large enough that they usually require writing a program in order
to solve them. Hardcore number crunching isn't a great domain for Ruby,
though, and the problems get quite advanced pretty quickly. I maxed out at
140 solved. But the problem solving skills of math complement the problem
solving skills of programming (imo, anyway). I found it very helpful for
developing problem solving skills, and figuring out how to transform what I
have into what I want.

I'm teaching some friends Ruby, and took a bunch of problems from a lot of
different places, they have automated tests that you can run locally, and
solutions also. If you're interested, let me know, and I can put up
installation instructions, so that you can try your hand at it. (you'll need
to have git installed to get updates, or copy and paste a lot of files, I'm
sort of building it as we go, there are 30 problems at present)
Some examples of the challenges
http://github.com/JoshCheek/JoshsRubyKickstart/blob/master/ch2/challenge/1_input_output.rb
http://github.com/JoshCheek/JoshsRubyKickstart/blob/master/ch2/challenge/12_classes.rb
http://github.com/JoshCheek/JoshsRubyKickstart/blob/master/ch3/challenge/3_hashes.rb
There are also solutions included (though many do not have a single correct
answer, and I try to keep the solutions within the scope of what we have
covered together).
 
L

Lakshmanan Muthukrishnan

Josh said:
On Sun, Jun 6, 2010 at 11:48 PM, Lakshmanan Muthukrishnan <

Codingbat.com has lots of simple easy problems, but it's mostly Java and
a
little bit of Python. Still, you can solve the problem however you like,
you
just won't be able to use their automatic tester.

There are also a bunch at spoj.pl but I found that site frustrating,
because
it's too dependent on string format of your output (a stray newline will
invalidate your solution, but you aren't given enough feedback to figure
out
what formatting needs to change) And their time constraints are aimed at
compiled languages, which frequently prevents Ruby from being a
possibility.

codechef.com is basically spoj.pl taken to the next level with a
community
and flashy design. But I have had a lot of trouble getting their Ruby to
work right for me, and they don't keep track of which solutions you've
previously solved, so you can't really make a goal of solving all the
problems they have. I'll probably try it again in 6 months or so, see if
they've made that stuff better.


......

Thank you so much
 
J

Jacob Mitchell

[Note: parts of this message were removed to make it a legal post.]

Search for "code golf". I personally have enjoyed
http://golf.shinh.org/because the problems tend to be very simple. It
helps you learn the pros
and cons of various languages.

-Jake

On Sun, Jun 6, 2010 at 11:48 PM, Lakshmanan Muthukrishnan <

Codingbat.com has lots of simple easy problems, but it's mostly Java and
a
little bit of Python. Still, you can solve the problem however you like,
you
just won't be able to use their automatic tester.

There are also a bunch at spoj.pl but I found that site frustrating,
because
it's too dependent on string format of your output (a stray newline will
invalidate your solution, but you aren't given enough feedback to figure
out
what formatting needs to change) And their time constraints are aimed at
compiled languages, which frequently prevents Ruby from being a
possibility.

codechef.com is basically spoj.pl taken to the next level with a
community
and flashy design. But I have had a lot of trouble getting their Ruby to
work right for me, and they don't keep track of which solutions you've
previously solved, so you can't really make a goal of solving all the
problems they have. I'll probably try it again in 6 months or so, see if
they've made that stuff better.


......

Thank you so much[/QUOTE]
 
R

Rick DeNatale

Search for "code golf". =A0I personally have enjoyed
http://golf.shinh.org/because the problems tend to be very simple. =A0It
helps you learn the pros
and cons of various languages.

-Jake

I strongly disagree that code golf is a good learning exercise for a beginn=
er.

The first goal of newbie should be to learn to write clean understandable c=
ode.

Code golf, where the goal is to write a program in the minimum of
characters, might be an interesting intellectual exercise, but it
leads to writing cryptic code which is just the opposite of what a
beginner should be learning.

Besides Dave Thomas code katas which Ryan mentioned. It might be
worthwhile to have a look at the old RubyQuiz site

http://rubyquiz.com/

--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
J

Jacob Mitchell

[Note: parts of this message were removed to make it a legal post.]

The way I've used code golf breaks with tradition. I try to write clean yet
concise code that solves the problem. It's a great way to start playing
with a language that you're not familiar with because, again, the problem
statements are *very* simple. It has helped me learn the basics of various
languages like the back of my hand.

-Jake
 
D

Daniel Berger

Lakshmanan said:
Hi,

I am reading ruby from the book "Programming ruby" and that book lacks
programming exercises. I want to work out some problems in ruby.

Please point me towards a good resource on the net or it can be a book
also.

Maybe it's name changed?

$ gem search -r nntp

*** REMOTE GEMS ***

nntp (1.0.0)
ruby-net-nntp (1.0.0)

Regards,

Dan
 
B

Benoit Daloze

Hi,
If you like math, projecteuler.net is a good choice, math problems whose
scope is large enough that they usually require writing a program in order
to solve them. Hardcore number crunching isn't a great domain for Ruby,
though, and the problems get quite advanced pretty quickly. I maxed out at
140 solved. But the problem solving skills of math complement the problem
solving skills of programming (imo, anyway). I found it very helpful for
developing problem solving skills, and figuring out how to transform what I
have into what I want.
I would like to thank you for the link to project Euler, it is really
interesting !
I would also recommend Ruby Quiz

Regards,
B.D.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top