views:

186

answers:

6

Hi folks--we're reading Programming Scala in our tech book club, and I'm thinking having a quick code dojo after the introductory chapters would be a good way to get our feet wet with the language before we proceed on. Does anyone have ideas for good programming problems that we could tackle in a 30-45 session that exercise basic Scala? If all else fails, we can always go for the standard phone screen questions, but it'd be cool to have something that lends itself to a scala-friendly solution. Thanks!

+3  A: 

I found this one pretty intresting

Nikolay Ivanov
+4  A: 

Try solving Project Euler problems with Scala.

missingfaktor
+4  A: 

There's a training released under the Creative Commons Attribution license. I have no experience with it, but it can't help but be a starting point, can it? :-)

Now, as for Project Euler and S-99 recommended in other answers, though I like them, please note that it will exercise the functional style, but will leave the OO features completely untouched.

As for other ideas, how about picking some unimplemented tasks in Rosetta Code for Scala? Or even some implemented ones. I personally think my Average/Mode solution is a thing of beauty. :-)

And speaking of things I did, I think my Matrix exercise is pretty good stuff, particularly if you try to implement it using Scala 2.8's Numeric.

Daniel
Daniel, those are really great ideas and resources you have there. Wow, thanks.
Unoti
+2  A: 

Why not have a go at a simple elevator sim (i'd say Lift but that might just confuse).

One elevator serving 2000 occupants of a building. The occupants are evenly distributed over 10 floors, ignoring ground. They all arrive randomly over 1 hour each morning. The lift takes a maximum of 10 people. Agree a time function for the journey time between any two floors. The system is aware of all presses of the lift call button.

Aim for the minimum total wasted time waiting for the lift for the whole population.

Lots of scope for case classes, actors, recursion and competition. You might even be able to sell the best algorithm ;@)

Don Mackenzie
+2  A: 

I would say, get a text file with words in it, for instance Romeo and Juliet from gutenberg.org. Then do things like:

  • count word frequencies and find the 10 most used words
  • find the 3 most used character names - may need to filter against these lists (A-K, L,Z).
  • make a search function that will return the line numbers where a Character name appears
  • make a search function that will return instances of Romeo if it appears within n words of Juliet
  • write a class that can perform the functions above on any arbitrary file or URL

That should provide you some exposure to:

  • reading a file
  • some of the collection classes
  • may be some pattern matching
  • writing a class

Then see if the solution can be posted as a single stack overflow code block that won't require horizontal or vertical scroll bars.

huynhjl
A: 

Thanks everyone for the responses. I think what we're going to do is pick a problem from the suggestions provided here at every meeting--starting with the more straightforward questions and working our way up. Thanks again for the help!

greg