# Problem / Language

0 views

### caike

Mar 18, 2011, 3:21:50 PM3/18/11
Hey,

Does anyone have any suggestions for either our language of choice or problem for tomorrow's session ?
If not, I'll try and come up with something tonight so don't spend too much time tomorrow.

--
Regards,
- Caike

### Eric Lavigne

Mar 18, 2011, 8:58:09 PM3/18/11
> Hey,
> Does anyone have any suggestions for either our language of choice or
> problem for tomorrow's session ?

Language: Clojure

Problem: Determine the optimal division of a list of trucks into
convoys so that they can cross a bridge in as little time as possible.

Some trucks need to cross a bridge. The order of the trucks is given.
Each truck has a weight and a speed. Several trucks can form a convoy
and cross the bridge at the same time if (1) those trucks are already
next to each other and (2) the total weight of the convoy is less than
what the bridge can bear. A convoy can cross a bridge in the same
amount of time as its slowest member would cross alone.

Example:
bridge_capacity: 100
trucks: [{weight: 40, crossing_time: 30}, {weight: 30,
crossing_time: 50}, {weight: 40, crossing_time: 20}]

In this example, we can divide up the trucks in four possible ways:
1) All at once - in which case the bridge collapses because 40+30+40 > 100
2) One at a time - in which case it takes 30+50+20=100 time to cross
3) Combine the first two - in which case it takes 50+20=70 time to cross
4) Combine the last two - in which case it takes 30+50=80 time to cross

The correct answer here is to combine the first two trucks for the
optimal time of 70.

This problem is easy to get started, with calculations about whether a
certain convoy is too heavy, or how long that convoy will take to
cross, but becomes more interesting as we find ways to decide how the
trucks should be divided into convoys. Once we have code that solves
the problem, we can also consider improvements for dealing with larger
number of trucks with reasonable calculation times.

### caike

Mar 18, 2011, 9:08:30 PM3/18/11
Hey, Eric.
Great idea for language and for the problem!

We can definitely use this for the 26th. In case you haven't read the other thread, we had to cancel tomorrow's meeting and push it for the following saturday.

Do you think you could setup the environment for our next Dojo in Clojure ?
What testing framework do you suggest ?
--
Regards,
- Caike

### Eric Lavigne

Mar 18, 2011, 9:42:18 PM3/18/11
Yes, I will take care of setting up the environment.

I usually use the test framework that is built in to Clojure, but I
really enjoyed having tests run automatically with Jasmine at the
Coding Dojo. Lazytest also does that, and I would like to give it a
try. It turns out that the same person created both the standard
Clojure test framework, which I usually use, as well as Lazytest. The
following article from last summer explains his reasoning for starting
over with a new test framework.

See you next week.

### Eric Lavigne

Mar 23, 2011, 8:19:31 PM3/23/11
Change of plans. I won't be at the next Coding Dojo, so someone else
will need to set up the environment.

I just received a job offer, and will be starting my first full-time
Lisp job in just a couple of weeks (MCNA Dental, Ft Lauderdale). I
will be very busy with moving preparations and studying their
technology stack, so I won't have time for Coding Dojo anymore.

For anyone who is curious about Clojure, I highly recommend this website:

### Jack Pines

Mar 23, 2011, 9:30:55 PM3/23/11
Good luck on your new endeavor, Eric. My wife, who calls SQL
"squirrel", thinks it's funny that you'll be working in Lisp for a
dental group. :-)

### Eric Lavigne

Mar 23, 2011, 9:41:12 PM3/23/11
That is funny - I hadn't thought of it that way :-)

### caike

Mar 24, 2011, 9:33:24 AM3/24/11

So, Mr David Rogers (a.k.a. General Consensus), do you want to lead us into Python land this Saturday ? :)
--
Regards,
- Caike

### David Rogers

Mar 24, 2011, 12:01:08 PM3/24/11
Sorry, guys, but I've been tapped to help in an emergency move in Winter Springs this Saturday, so I won't be able to come. If we're done with the move before you're done with the dojo, though, I'll try to catch up.

On an unrelated note, who wants to help present on the dojo at Barcamp next weekend?

--
David Rogers
Sent with Sparrow

### caike

Mar 24, 2011, 1:55:26 PM3/24/11