Browse > Home / Archive: September 2009

| Subcribe via RSS

Random Football Picks in Groovy

September 25th, 2009 | 1 Comment | Posted in Code

My friend runs an informal football picks contest every week and I thought of a way to participate in a very geeky way, a program that would make my picks for me. I decided it would be funny to write a program that would randomly make my picks for me since everybody else spends an inordinate amount of time thinking over their picks. Plus, I don’t pay attention to football so my picks would have been essentially random in any case.

The contest is simple; pick who you think is going to win in all the games. The person with the most correct picks wins. You also guess how many points the next Monday Night Football game is going to have in total so if there’s a tie, whoever is closest to that number wins.

Here’s the code for my program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def matchups = [1 : ['Atlanta','Carolina'],          2 : ['Detroit','Minnesota'],
 3 : ['Green Bay','Cincinnati'],      4 : ['Jacksonville','Arizona'],
 5 : ['Kansas City','Oakland'],       6 : ['New York(NYJ)','New England'],
 7 : ['Philadelphia','New Orleans'],  8 : ['Tennessee','Houston'],
 9 : ['Washington','St. Louis'],     10 : ['Buffalo','Tampa Bay'],
 11 : ['San Francisco','Seattle'],   12 : ['Chicago','Pittsburgh'],
 13 : ['Denver','Cleveland'],        14 : ['San Diego','Baltimore'],
 15 : ['Dallas','New York(NYG)'],    16 : ['Miami','Indianapolis']]
 
def rand = new Random(System.currentTimeMillis() + Runtime.runtime.freeMemory())
matchups.each() { key, value -> println("${value[rand.nextInt(2)]}") }
 
def score1 = rand.nextInt(5) * 7;
def score2 = rand.nextInt(5) * 3;
println("${score1} + ${score2} = ${score1 + score2}")

I’m a Groovy newbie, one of the reasons I wanted to use the language for this little thing, so I don’t know if this is the best way of doing this but this turned out to be pretty quick and easy. The hash/array data structure I used for the matchups variable makes it very easy to pick the various winners with the one-liner on 11. I went with a recommendation I found for super-extra randomness on 10 just make sure.

In the end, my random picks weren’t all that accurate. I think I had 5 right out of 16. There’s randomness for you, so unreliable. :) I also learned that when a random number generator makes your picks, you can’t take the blame for making bad picks but you also can’t take credit for the ones you got right.

Feel free to steal this code if you want to make your own picks. You have to put in all the matchups for the week but I tried to format the code so I could make the list in UltraEdit using its column-editing mode and just drop the teams in. If you have a more Groovy-ish way I could have done the matchups I’d love to hear it in the comments.

I do like my profession, I don’t like my job

September 14th, 2009 | No Comments | Posted in Business, Code, Work

To only a fraction of the human race does God give the privilege of earning one’s bread doing what one would have gladly pursued free, for passion. I am very thankful.

The Mythical Man Month, p. 291

via CLOSED-LOOP: The passionate developer: I do like my profession, I don’t like my job.

This is great stuff. I’ve always felt the way Fred Brooks talks about in that quote and this post captures a lot of how I feel about my job as well. Well worth reading.

If architects had to work like software developers

September 8th, 2009 | No Comments | Posted in Business, Code

Dear Mr. Architect:

Please design and build me a house. I am not quite sure of what I need, so you should use your discretion. My house should have somewhere between two and forty-five bedrooms. Just make sure the plans are such that the bedrooms can be easily added or deleted. When you bring the blueprints to me, I will make the final decision of what I want. Also, bring me the cost breakdown for each configuration so that I can arbitrarily pick one.

Monochrome Blog – If architects had to work like software developers.

Painfully true. Very painfully.

I’m trying to decide if sending this to our product owner would be informative or insulting.

My Long Walk

September 3rd, 2009 | No Comments | Posted in Code

Awhile back I was inspired by a post on a local Albuquerque group blog called Duke City Fix about a guy who walked across town, taking pictures along the way. I’ve always liked walking and thought it would be cool to do a similar walk. Every place I’ve worked at I’ve taken my lunch hours and walked around, sometimes taking pictures but mostly just exploring. You find a lot of neat stuff walking since you’re moving slow and you’re close to the ground. Even if you’re in an office park or urban area I’d encourage you to try walking around and seeing what you see. You might be surprised.

For my walk I decided to go on Montgomery since it goes basically from one side of Albuquerque to the other. It also goes across the river and through our Bosque / North Valley area which is by far my favorite walking area in town. I started at Tramway, the east side of the city, and walked all the way to Coors on the west side. It’s 10.9 miles according to Google Maps and with a couple of small detours I made I think I pretty much did exactly 11 miles. This is far longer than I’ve ever walked before but I did it. :)

My Long Walk Route

My Long Walk Route

Google said it was going to take 3 1/2 hours, which is about 20 minutes per mile. I thought this was doable but I didn’t factor in the heat. It was 81 degrees an hour or so after I started but it got up past 91 a few hours in. This meant I needed to rest and refill my water bottle more often than I anticipated (thank you McDonalds for having cold water, air conditioning, and 3 locations along my route!). It ended up taking me 4 1/2 hours with rest breaks.

I did a sort-of live tweeting of the walk, which you can find on my Twitter stream. The tweeting was fun for me, and helpful with the nice encouragements I got from my friends on there. That’s another nice thing about walking, you can do other stuff at the same time. It’ s hard to tweet from a bike. :)

The other part of the walk was taking pictures. I decided against taking my regular camera with me on this first walk since I was already carrying a water bottle, so I took some pictures with my iPhone camera instead. It’s cool to be able to upload the pics to Flickr while walking too. The whole set can be found at Flickr if you’re interested.

I’m very glad I did this walk, even with the heat and pain my poor legs felt later. I’m already thinking of how I would do a similar walk going North/South across town in fact.

For now though, here’s a picture of why the North Valley of Albuquerque is my favorite walking area. Right on the other side of this wall is one of the city’s busiest streets and you’d never know it.

The valley is my favorite walking area

Must Be Questioned

September 1st, 2009 | No Comments | Posted in Art

The World Used To Be Flat

Indexed » Blog Archive » The world used to be flat.

I’ve been following Jessica Hagy’s work on Indexed for a long time and I’m always glad to see her getting more and more popular.