The first question in Round 1A of the 2015 Google Code Jam is a great example of a problem that can be solved very easily in just a few lines of Julia.

The question goes like this:

Kaylin loves mushrooms. Put them on her plate and she'll eat them up! In this problem she's eating a plate of mushrooms, and Bartholomew is putting more pieces on her plate.

In this problem, we'll look at how many pieces of mushroom are on her plate at 10-second intervals. Bartholomew could put any non-negative integer number of mushroom pieces down at any time, and the only way they can leave the plate is by being eaten.

Figure out the minimum number of mushrooms that Kaylin could have eaten using two different methods of computation:1)

Assume Kaylin could eat any number of mushroom pieces at any time.2)

Assume that, starting with the first time we look at the plate, Kaylin eats mushrooms at a constant rate whenever there are mushrooms on her plate.

For example, if the input is 10 5 15 5: With the first method, Kaylin must have eaten at least 15 mushroom pieces: first she eats 5, then 10 more are put on her plate, then she eats another 10. There's no way she could have eaten fewer pieces. With the second method, Kaylin must have eaten at least 25 mushroom pieces. We can determine that she must eat mushrooms at a rate of at least 1 piece per second. She starts with 10 pieces on her plate. In the first 10 seconds, she eats 10 pieces, and 5 more are put on her plate. In the next 5 seconds, she eats 5 pieces, then her plate stays empty for 5 seconds, and then Bartholomew puts 15 more pieces on her plate. Then she eats 10 pieces in the last 10 seconds.

The key observations are that for the first method, the solution is simply the sum of the negative differences across Kaylin's plate between each time step. For the second method, you need to determine the time step that has the greatest decrease, and then let Kaylin eat either that number of mushrooms or the number of mushrooms on her plate, whichever is fewer.

A solution in a traditional programming language like C++ or Java takes 10-20 messy lines of *for* loops. You can download such implementations from the contest scoreboard. However, I present a 3-line solution using Julia (14 lines if you include my comments and I/O).

```
# Read input
T = int(readline(STDIN))
for t=1:T
N = int(readline(STDIN))
M = int(split(readline(STDIN)))
# Compute solution
deltas = M[2:end] - M[1:end-1]
n1 = -sum(deltas[deltas .< 0])
n2 = sum(min(-minimum(deltas), M[1:end-1]))
# Print result
println("Case #$t: $n1 $n2")
end
```

The implementation can be run from the command line as `julia mushroom.jl < mushroom.in`

where *mushroom.in* is your input file.

For those who don't know, Julia is a new programming language, originally designed for scientific computing. Its syntax is similar to MATLAB/Octave, but under the hood it uses strong typing to speed up execution and give more flexibility for fast scripting. Like Romeo, I've fallen in love with Julia and don't expect to be switching to a different language any time soon. :)