Blog Post on CircleMUD Data Conversion

March 23rd, 2012

I converted all the monster/weapon/item/map data from CircleMUD (an old piece of MUD server software) to XML from it’s native, hard-to-parse text format. More info and download links on the blog post on my Invent with Python blog.

Some Blog Posts on Programming

March 23rd, 2012

I wrote a couple blog posts on my Invent with Python site about programming:

“How much math do I need to know to program?” Not That Much, Actually.

Nobody Wants to Learn How to Program

My new book: “Making Games with Python & Pygame”

February 10th, 2012

I’ve completed my next book, which focuses on the Pygame library and making graphical games in Python. It assumes you have a little bit of Python programming knowledge. The book is free to read online from http://inventwithpython.com/pygame and can also be bought on Amazon.com for $25.

Thanks to everyone who helped me out with this book over the last year and a half.

Nobody Cares About a Few Million Nanoseconds

August 19th, 2011

Note: This article originally appeared on my programming book’s blog.

A Clever Programming Trick…

If you need to swap the values of two variables, this usually requires a third temporary variable (that is, if you’re not using a language like Python that supports the a, b = b, a syntax.) It looks something like this:

temp = a;
a = b;
b = temp;

But if these are integer variables, there’s a nifty trick to save yourself a little bit of memory. You can use arithmetic instead of a temporary variable:

a = a + b;
b = a - b;
a = a - b;

If the integers on your platform are 32-bits, your new swap will save four bytes of memory.

NOBODY CARES ABOUT FOUR BYTES OF MEMORY. (more…)

Vampire Numbers Visualized

July 19th, 2011

Vampire numbers are fairly interesting. Vampire numbers are numbers whose product contains the same digits as the two vampire numbers. For example, 21 x 60 = 1260. The two vampire numbers (called “fangs”) must be the same length and both cannot end with a zero. A longer example is 68088 x 45321 = 3085816248. You can find out more about these numbers on Wikipedia.

It’s fairly simple to write a program to calculate vampire numbers. I was somewhat bored and went ahead and wrote one up. Download the vampire number generator.

I’ve gone ahead and calculated all of the vampire numbers up to five digits. You can download the full text file of vampire numbers here (zipped, it’s about 1.06 MB). The nifty thing is, if you plot these numbers on an image with the two fangs being the X and Y coordinates, you get a pretty interesting image. This image is 500×500 pixels and covers the range of 0 to 100,000. Each pixel represents a 20×20 range of numbers. The more dense this area is with fangs, the darker the pixel is colored in. The 0, 0 origin is in the lower left. The final image has an interesting pattern:

Next Page »

Powered by WordPress