Posts Tagged ‘programming’



i miss you, world!

Saturday, February 21st, 2009

aha! I’m lame. Haven’t updated in.. yes… 2 months and 6 days. I believe that officially puts me in the world of “suck”. Redbrain from #linuxoutlaws (@freenode) actually said to me almost a month ago: “Hey, nice blog man, keep it up!” and I said to myself “Man, I really should update that”. But I didn’t. There are no real excuses, but I’ll make some anyways, namely:

  1. STL, I love you, but I hate you. Templates, You guys can suck a fatty too. You’re so useful, but just such a pain in my patoot. Of course, I treat you well when we’re writing together on our own… but the pain you cause me when you’ve run off with someone less responsible than me is excruciating. Where’s the love?
  2. Haskell … oh boy Haskell. When I discovered the ease of Python after being raised in the world of C/C++, Python was the Orinoco Flow of my programming world! Light and airy, I swear as I checked my indentation that first time that around the world hippies were swaying and holding hands rejoicing about something or other. But Haskell.. you dirty rascal.. you’re my Korpiklaani. You’re a wild beast that’s angry and ready to be let loose on anything that needs a quirky methodology, and yet at the same time, you’re catchy, and enjoyable, and oddly enough, make perfect sense. I don’t know what it is about Haskell (or Korpiklaani, for that matter)… it’s clunky syntax and functional modus operandi are bewildering, but I like the way it works. So much of Project Euler, if done in Haskell, are one-liners, and the flow of them actually makes sense. Haskell seems like doing surgery with a chainsaw, and miraculously, the patient not only is cured, but has grown organs for breathing underwater and x-ray vision. It’s just got that kind of whiz-bang.
  3. Left 4 Dead. I haven’t had much time to play, but boy oh boy. If you haven’t seen this game somehow.. let me sum it up for you: Post-apocolypse + Zombies + shotguns + multiplayer first-person-shooter = love.

And that, boils and ghouls, has been what my last two months has been all about. Let’s see if I can make it around to actually post again before I’m 70.

project euler #9

Friday, September 5th, 2008

Many of you know I’ve been sucked into the world of Project Euler. I love problem-solving with computers, and I love math, despite not being great at problem-solving with computers and being even worse at mathematics.
As of yet, most of my solutions have been brute-force attempts which get the answer quite ahem thoroughly, if not the most efficiently.
Well, project euler #9 involves calculating pythagorean triplets, and I’d left it for a while deciding it would involve a pain-in-the-ass buttload of calculating and would take about 20 minutes to run. However, I’ve been listening to The Teaching Company’s The Joy of Thinking, and they presented ways of calculating the pythagorean triplets that I’d never really thought of.
Anyways, this morning I was waiting around for a while between errands, and a napkin and 4 lines of python inspired me. All I had to do was reduce the fact that:
2mn+(m*m - n*n)+(m*m+n*n) = 1000
to
m(m+n)=500 and run through m and n with n < m. BAM!

[nate@pepper python]$ time ./peuler9.py
sum = 1000
product = *****

real 0m0.012s
user 0m0.010s
sys 0m0.000s

Yes, I removed the actual answer so as not to be a spoiler. However, I will include my full source code, as I’m amazed at how simple it was, and maybe you’ll enjoy it too.
(source code after the jump…)
(more…)

general updatery

Friday, September 5th, 2008

Boy, is school ever busy!
I really dig my new position as a lab assistant. I get to help people, which I’ve always considered a good thing. In some ways, it’s kind of crappy, becuase in the classes that don’t end up needing a lot of technical assistance, I end up getting sent to make copies or working on stuff for project euler, but I consider it well worth it.
Classes are going good too. I’ll be essentially sleeping through my german class, but it will be an easy 5 credits. Might even get fun too.
I had my first C++ class in almost 10 years last night. THAT was a trip. Back when I started learning, STL had barely come into existence. We had only just got up into the process of implementing classes and whatnot. After that, I ended up doing all python and perl and ruby, and who needed to compile?
I got into this class and after our introduction, one of the first comments was “Well, I’m sure you’re all familiar with things the string classes and whatnot, so let’s move on to memory addressing and pointers”
/me jaw_floor()++;
Good news is, it’ll actually be a nice challenge to catch up.
I haven’t been to my Shell Scripting class yet, but it should be alot of fun. It’s with one of my favorite professors, so I plan on it being a fun time.
More later.