Tuesday, June 15, 2010

Euler Problem 1

Problem:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.


Solution:

function euler1 (range)
local result = 0

for i=3,range do
if (i % 3) == 0 or (i % 5) == 0 then
result = result + i
end
end

return result
end

print(euler1(999))


There's really nothing clever here, I just used the most straightforward way of accumulating the results imperatively. Mostly boring stuff, but now we are underway!

Monday, June 14, 2010

Project Euler

I am taking on a new endeavor:

Project Euler [http://projecteuler.net]

I am going to post solutions to these problems in a new language I'm learning, called Lua. [http://www.lua.org/]

This should help me exercise my programming skills while also helping me become more familiar with a new language. Here's why I picked Lua:

1) Powerful - Lua can be embedded in virtually any other environment and has mechanisms for doing just about anything you can think of.

2) Performant - Using LuaJit, it may be the fastest scripting / dynamic language out there.

3) Portable - It runs nearly everywhere without changing the code one bit. This is becoming more an interesting feature as the mobile world booms, with ARM processors.

4) Practical - It's a small language, with many similarities to JavaScript, but without a lot of the bad design in JavaScript. It's simple to use and just get things done. If it's not there in Lua, it's trivial to call a C function that does the job for you.

I look forward to posting my solutions, it should be fun and helpful. I hope everyone that stumbles on my blog by accident finds it as fun and interesting as I do!

-DR

Monday, May 24, 2010

To Koby

You will always be my dog, and you've been a wonderful companion. We had a good run, 15 years is a long time. When you came home to us, I was a totally different person than I am now. A lot has changed for me: interests, talents, preferences. Back then I even begged for you to be named Sterling, so Mom and Dad let that be your "middle name" just to please me. But you've been there all along, a reliable member of the family.

I remember all the days when you'd come jump on my bed (this was back when you could still jump). You were smart enough to figure out how to open my door, and you'd pounce on me and perk up your ears while letting your tongue hang out. It was hard not to smile, and you never seemed to care what all was going on.

Come to think of it, you were great at just hanging out. It didn't take you long to figure out that Patrick and I loved video games and tv, and rather than chew up our stuff, you quickly learned to veg out with us in front of the tv too. Over the years, you've even taught us the fine art of power napping! (You scared mom a couple times when you wouldn't wake up).

Sure you had your quirks and weird habits, like chewing up my toothbrush a couple times (what was up with that?). There were a few others that I won't mention! You also drove mom nuts when you threw up on the carpet, but we still haven't told her you were mostly nervous about Favre coming back from retirement. Overall you always gave things a good effort though, even when you were totally confused with what was really going on (like when we wrestled with dad).

There were a couple times where you paced so much that mom figured out we were up to something (why couldn't you have just gone and taken a nap, you got us in trouble!)

I won't forget your bad breath or how bad you made the car stink on long trips, but I guess we still enjoyed having you around. After all, you've got some serious skills. You could play football like nobody's business, and even though you had a short memory, you were pretty decent at finding us playing hide-and-go-seek. You had a pretty good set of tricks, and even when you couldn't roll over anymore, you still tried your best.

I remember how much you loved the first snow of the year, you'd rub your nose in the snow and run around like crazy! I also remember that you would just lay down when your feet got cold, and we had to come get you (not fun). I don't think I've known anyone who liked popcorn more, if you could have pulled it off, I think you would have stood on one leg to get a piece of popcorn!

All in all, though, your best skill was survival. Koby the Wonderdog, the dog with 9 (or more) lives! You stared certain death in the face numerous times, and we still don't have a clue how you survived most of them! I've got a picture of the two of us that is probably ten years old now, from when the vet said you had less than 24 hours left to live.

Well Koby, it's finally over. Now it's time to show the world your finest trick. We always asked you if you'd rather be a Democrat, or be dead. You've never chosen Democrat, so it's fitting to see you pass on in peace. Rest well, old friend.

Tuesday, November 18, 2008

The Cuban Missle Crisis

Mark Cuban got into some trouble yesterday, with the SEC filing a charge against him for insider trading. Hey, what's a guy have to do to keep from losing money in the stock market these days?

It's been an interesting day, I locked myself out of my car this afternoon. Adam gave me a ride up to class, and then Quinn picked me up so that we could go back and get my car. That's about how this week has been going. I've lost a hat and a flashlight, and spent forever trying to find them (finally found the hat). I'm also having difficulty getting anyone to respond to my emails, both at school and work possibilities (a job offer).

The exciting thing is that I'm really loving work right now, I'm getting to learn some neat stuff and I enjoy working with my coworkers. What this means in the big picture is that I'm actually excited to be almost done with school.

Saturday should be one of the best football games I've seen in my lifetime, but then again there are always those that disappoint. Green Bay will also be on MNF, so I'm pumped to get to see my team play on National TV.

Oh, by the way, I can smell the turkey cooking already too, which means good food, football, and a break from school!

Thursday, November 6, 2008

The End is Near

No, this isn't a political post, although the title fits nicely with what a lot of people have been suggesting lately.

The end for me is graduation, and in about 6 weeks I should be a free man (well, I'll still be married, but at least I won't be a student anymore!)

I've made the rounds for job interviews, and have had some luck. Right now I'm working part-time for a web design company (they do more than just that, but that is my job). I've also got some pending hopefuls for full-time stuff after school. Quinn and I are staying super busy, but we're feeling like we're using our abilities to accomplish stuff.

As most people know by now, the stock market took a dive, and that has reduced my trading of stocks, but not my investment in them. I've chosen some good companies to lend my money to, and they've all done surprisingly well in their earnings the past quarter.

The Twins almost made it to the playoffs, it doesn't look like the Packers or Jets will be Superbowl contenders, but the Sooners find themselves in the middle of quite the year for the Big 12 South.

Now that I've covered everything very briefly, let me say that life is good. Quinn and I have gotten involved at church and made quite a few new friends. Not a bad stretch of months for us, things are definitely shaping up to be great once we're both out in the real world.

That is all.