Cryptarithm

Posted by CPUFreak91 on November 10th, 2008 filed in Programming, Project Difficulty: Hard, Python, Time Spent: More than 2 hours
Comment now »

Here’s my first attempt at brute-forcing a cryptarithm puzzle with no previous knowledge on how to solve them in Python.

The puzzle is: HACKER + HACKER + HACKER = ENERGY

The solutions are:
124536 + 124536 + 124536 = 373608
205463 + 205463 + 205463 = 616389

And here’s the code :).

# "Hacker"
# "Hacker"
# "Hacker"
#+________
# "Energy"

min = 100000 #Can't be less than 300,000 because 1/3 of it would be less than 100,000 which is less than the num of letters in hacker or energy

max = 333333
tries = 0
solutions = 0
listOfNumbers = []

for number in range(min, max):
listOfNumbers.append(number)

for number in listOfNumbers:
duplicate = False
sumString = list(str(number*3))
individualString = list(str(number))

for letter in individualString:
if individualString.count(letter) > 1:
duplicate = True

duplicate2 = False
duplicate3 = False
duplicate4 = False

sumString2 = [sumString[1], sumString[3], sumString[4], sumString[5]]
individualString2 = [individualString[0], individualString[1], individualString[2], individualString[3] ]
for letter in sumString2:
if sumString2.count(letter) > 1:
duplicate2 = True
for letter in sumString:
if sumString.count(letter) > 2:
duplicate4 = True

if duplicate == False:
if duplicate2 == False:
if duplicate4 == False:
if (sumString[0] == individualString[4]):
if (sumString[2] == individualString[4]):
if (sumString[3] == individualString[5]):
for digit in individualString2:
if digit == sumString2[0]:
duplicate3 = True
elif digit == sumString2[1]:
duplicate3 = True
elif digit == sumString2[2]:
duplicate3 = True
elif digit == sumString2[3]:
duplicate3 = True

if duplicate3 == False:
print number, “+”, number, “+”, number, “=”, number*3
solutions += 1

tries += 1

print “Took”, tries, “tries to generate”, solutions, “solutions.”

I first started out by generating and brute-forcing an array of numbers between 100,000 and 333,333. I looked for duplicate digits inside the numbers and sorted through them several times but making sure that the 5th digit of the summed numbers was the same as the 1st and 3rd of the sum of the numbers and that the 6th digit of the summed numbers was the same as the 4th digit of the sum of the numbers.


Free Music — And how to get it (legally!)

Posted by CPUFreak91 on September 4th, 2008 filed in Web Stuff
Comment now »

You don’t have to go to bittorrent to find good free music. If you’re not looking for the latest greatest biggest artist hits, you can find some nifty free stuff in plenty of places!

iTunes: iTunes has a Free Single of The Week you can download. It has/usually has their FairPlay DRM

Magnatune.com: Actually, you can download the MP3s from Magnatune and not pay a cent, the only catch is that a voice will come on at the end of the track and say the track number, artist name, album name and “Magnatune.com”. They also have a Free Song of the Day which they’ll send to you when you give them your email. No DRM!

eMusic.com: You can get 25 free songs if you use your credit card and apply for their 7-day free trial. You can cancel at anytime, but you still need a credit card, and you need to remember to cancel–otherwise you’ll get billed. No DRM!

Amazon: If you subscribe to their weekly newsletter you can get a couple free downloads, and special deals. No DRM!

Napster: Another, gimme your creditcard have a few songs for free, cancel whenever. No DRM!

Insound: These guys will give you a free song in MP3 and there’s quite a few choices. No DRM!

There’s plenty more online music stores to chose from, and if you dig around on a few, you’ll probably find some free music. (Google is your friend).


Migrating an SVN repository from your site to SourceForge’s

Posted by CPUFreak91 on August 13th, 2008 filed in Programming, Project Difficulty: Easy, Time Spent: Less than 1 hour, Web Stuff
Comment now »

Since Roger Robot is now a SourceForge-hosted project I wanted to migrate the SVN repository from my webhost to SourceForge’s svn server. I found some instructions, ssh’ed into my webhost and ran these commands:
svnadmin hotcopy
svnadmin dump path to svn repository itself, not the checked out version> -r 0:HEAD > .dump
bzip2 .dump

Then I fired up the sftp client, logged into shell.sf.net and transferred the dump file to Roger Robot’s SF.net group folder. The process took ages, but once it was done, I went into the Admin panel for the Roger Robot project, selected SVN, clicked on the obscure “Migrate” link, typed the name of the dump.bz2 file and the name I wanted the new repository to have (the repository on my server is name pyweek6, I wanted the sf.net one to be roger-robot).


Fixing Wordpress “You do not have sufficient permissions to access this page.”

Posted by CPUFreak91 on August 13th, 2008 filed in Project Difficulty: Medium, Time Spent: Less than 1 hour, Web Stuff
Comment now »

I kept getting this error after I upgraded from WP 2.3 to WP 2.5 and restored its database.

I found the solution off of some guy’s blog. Works well!

Basically you have to know if you changed the prefix of your table names in WordPress after the migration.

From the blog:

In my old database, I used ‘wp_’ as my prefix. As I migrated, I decide to use ‘wp3_’ instead of ‘wp_’. Unfortunately, the meta_key values are tied down to:

wp_user_level
wp_capabilities
wp_autosave_draft_ids
I need to update it to

wp3_user_level
wp3_capabilities
wp3_autosave_draft_ids
I wrote an SQL statement to share, just replace ‘prefix_’ with your new WordPress prefix. The following statements go to ‘meta_key’ and does a string replace from ‘wp_’ to ‘prefix_’.

UPDATE `prefix_usermeta` SET `meta_key` = REPLACE( `meta_key` , ‘wp_’, ‘prefix_’ );

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

In the options table, there is ‘wp_user_roles’, make sure you get that changed into ‘prefix_user_roles’.

UPDATE `prefix_options` SET `option_name` = ‘prefix_user_roles’ WHERE `option_name` =’wp_user_roles’ AND `blog_id` =0;

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

With everything set, I tried logging in again and it worked. A happy WordPress user once again. I am using WordPress 2.2.2 before the migration and I did not upgrade WordPress during the migration. Hope it helps. (Applies to WordPress 2.3.3 also.)

This works for 2.5 too :D


Day 7 Of CDN ‘08 Speedgame

Posted by CPUFreak91 on August 7th, 2008 filed in Game Competitions, Games, Programming, Project Difficulty: Easy, Time Spent: More than 2 hours
Comment now »

Today I learned a new thing about game making. Artists need inspiration! Lots of it at times. During the start of this speedgame, Jeff and I had talked about doing this together. We weren’t too sure he’d get a chance to do the art, so I went all over the web looking for placeholder art.

When I showed Jeff a demo I got a different response than I expected. Other than traces of artistic repulsion, seeing an ugly world inspired him to make it better. He got no inspiration from seeing my ideas written down, but immediately grasped the feeling that I was creating with the game world when he got to see the demo with placeholder art.

I’ve learned a valuable lesson, don’t ever wait for any art whatsoever. Just find some placeholder art to throw in the game. Your artist will most likely be very inspired.

On a side note, I haven’t gotten anywhere with new gameplay. I have, however, created a better looking world. :)


Day 1 Of CDN Speedgame ‘08

Posted by CPUFreak91 on August 2nd, 2008 filed in Game Competitions, Games, Programming, Project Difficulty: Medium, Time Spent: More than 2 hours
Comment now »

After spending most of the morning getting nowhere (except finding semi-cool art on the ‘net) I have finally got the basics of a game down.

Much of my morning was spent either designing the level or trying to be able to pick up objects. I finally got the object picking-up stuff almost completed, but there’s a lot more level designing and building to be done.

However, I have completed the basic instructions, and pretty much every object in the game can be picked up (however everything turns into a crate when you drop it. Need to fix that). The first basic puzzle has almost been completed. You pick up a crate, put it on the scale, and then jump on the scale and get to the next floor. The only thing missing is having the scale weigh the objects to see if they’re the same.

The game looks pretty good, even if there’s some noticeable visible glitches from my hacked walls, floors, and ceilings. My own in-house code to borrowed code ratio is way out of balance, but I should be able to fix that soon.


The Same Experience

Posted by CPUFreak91 on July 29th, 2008 filed in (K)Ubuntu, Macintosh, Project Difficulty: Medium, Web Stuff
Comment now »

Recently I’ve been working on narrowing the gap between Mac OS X and Kubuntu. Since Mac OS X isn’t too configurable, I’ve modified Kubuntu to look more like its cousin. Visually I’ve achieved narrowed the gap with Avant Window Navigator (for the dock), KDE4 for visual effects and “Expose”, but there was still something missing.  I wasn’t getting the same experience on both operating systems.

This all changed when I met Flock. Flock is a modification of Mozilla Firefox that is more social oriented. Flock provides a Twitter client, Facebook client, RSS reader, integrates nicely with Webmail, and even displays your Del.icio.us bookmarks when you type URLs into the navigation bar.

Normally I’d turn down a Gecko-based rendering engine’d browser because I like KHTML/WebKit better. However, I’ll get rid of my fanboy tendencies when I meet something truly useful. Flock is my Killer Cross-Platform App. Sure, I could wait until Konqueror 4 comes out for Mac, but Flock is more useful.

There was a quirks I had to iron out thoguh. I downloaded the Flock 2 beta, and tried to get flash to work on it in Linux. Didn’t work. After much hair pulling and combing the web, I realized Kubuntu was providing the npwrapper implementation of the 32-bit flash library to work with my 64-bit browsers. Because I had the 32-bit version of Flock (I need to find me the 64-bit version) it was choking on the “64-bit” Flash libraries. I went to Adobe’s site, downloaded Flash 9 for Linux, extracted the library, and copied it to ~/.flock/plugins.

Now I have the same experience on both OSes. There are a few killer apps, like Unity on OS X, and KDE Linux experience itself (yes, that’s my killer “app”) on Kubuntu that I can never get to work on the other OS, but that’s nothing but a quibble. When I want to watch a video, I fire up VLC, on either OS. When I want to chat with someone I fire up, Konversation (on Kubuntu) or Colloquy (on OS X) which function and look fairly similarly. Music is a bit rough, Amarok on Kubuntu and iTunes on OS X, but once I stop being lazy and download the Mac builds (they’re only in torrent form right now :( ), my music experience will be the same also.

Why this need for a similar experience? Why make a Grany Smith Apple look like a Red Delicious? Humans (well, maybe just me) like things that are familiar to them. Sure I’ve been using KDE for almost two years now, and OS X for over one year, but the drastic change of environment when I rebooted irriated me somewhat. Now when I want to use my computer I just use it. I no longer debate which OS to boot into based on my aesthetical mood. It Just Works (TM), and i don’t have to Think Different (TM) ;).


Wordpress Restore

Posted by CPUFreak91 on June 13th, 2008 filed in Opinions
Comment now »

The other day I was moving a WordPress blog off of my computer and onto DreamHost. I upgraded the database and everthing was peachy–until I found out that I didn’t change the blog URL. I could got to the DreamHost url and it would redirect me right back to 127.0.0.1 when I tried to log in. Lovely. So I went into PHPMyAdmin and found the blog urls (I think it was in the wp_options table) and changed them to point to the proper place. Thank you PHPMyAdmin for a simple, efficient way to change MySQL table entries!


I’m All Web 2.0 Now

Posted by CPUFreak91 on June 4th, 2008 filed in Opinions, Web Stuff
Comment now »

I’m typing this from Adium, a Mac instant messenger client. If wishes were horses, we’d not only be eating steak, but we’d be able to control anything from our instant messenger client.

I’ve recently discovered IMified, a service where you add IMified’s bot to your buddy list (AIM: IMified, GTalk and MSN: imified@imified.com). It is a productivity tool that offers instant access to a growing number of web applications over your instant messaging client. Imified simply helps you get things done faster. I edited my account after adding the bot to my buddy list and found 3 amazing “widgets”:
Twitter Updater and Notifier (I haven’t gotten a new Tweet from anyone to test the Notifier)
Remember The Milk (Add and view your Remember The Milk TODO list. Doesn’t seem to notify you of overdue stuff though.)
And finally, the widget I’m using now: WordPress (Need an explanation?).

I’m a console/terminal person. I like typing commands. Thus, I wish to control everything that sends and receives plaintext with my IM client. Here’s what IMified needs to be nearly perfect:
An IMAP client: Send and receive emails from an IMAP account. “Import” your contact list.
PhpBB posting (and/or other Forum software): Read and post topics. Manage your PMs
WordPress: Yes, there already is one, but I need to be able to select categories, and edit and delete posts.

That’s about all I can think of right now. I’ll edit this post in a web browser (grr :P) when I think of more.

Web Browser Edit:
Now about the Web 2.0 part of the title of this post. When I signed up to Facebook, I loved the status blurb you can write about yourself. But I didn’t want to have to log in, click a link and edit my status (I dual-boot and thus reboot frequently) so when I discovered Twitter, I found the perfect status/mini-blog updater. I searched Facebook for a Twitter App and found one that updates my Facebook status from my latest Twitter post. Shortly after, I discovered IMified. I added the Twitter widget, and discovered I had an status update system that works like this:
MSN –> IMified –> Twitter –> Facebook. One API after another. That’s the only thing about Web 2.0 I’ve ever been excited about.


tesseract Optical Character Recognition and GIMP

Posted by CPUFreak91 on April 9th, 2008 filed in Project Difficulty: Easy, Time Spent: Less than 30 minutes
Comment now »

I discovered tesseract when looking for an alternative Optical Character Recognition program to use in SANE. Unfortunately tesseract can’t be used by SANE unless there’s the possibility of setting a bunch of different .TIFF save settings. I decided to try my luck at images off the ‘net that had text in them. I took some screenshots of a few images with clean-ish white backgrounds, saved them as uncompressed TIFF and ran tesseract on them… nothing. So I searched the net. A Linux Journal article showed me all the steps one has to take to get a TIFF image to work in tesseract.

First, you must go to Tools→Color Tools→Threshold and change the image’s threshold until it looks as clear as you can make it.
Second, convert the image to Indexed mode with Image→Mode→Indexed and select the black and white (1-bit) palette.
Third, Remove the Alpha Channel by going to Layer→Transparency→Remove Alpha Channel
Fourth, save the image as .TIFF without any compression.

Then you can run tesseract on the .tiff image and, if the image isn’t too cluttered, you’ll see a 90%+ accuracy in the converted image!