Graphs can be made with pointers or an array configuration.
Speed is of the essence in this application. Why? The sheer number of permutations.
Flexibility isn't important. I don't need the full range of capabilities of a directed graph. Each vertex needs a right and a down edge.
But how many permutations are there? Curious.
There are nine items that can be arranged.
Permutations http://en.wikipedia.org/wiki/Permutation. 9! == 362880
But each card has four positions. Crud. (How did I calculate this again?) 4**9 comes to mind.
Friday, July 8, 2011
Wednesday, July 6, 2011
Vess Cola, Part 2.
The problem is how to represent the 3x3 grid of Vess Cola cards in such a way that I can compare the color and bottle top/bottom. Red Top must match Red Bottom, and so forth.
At first glance, a good data structure to represent the cards' grid would be a directed graph.
A directed graph would be simpler than an undirected graph. The compare only needs to work one way.
For example, Card 0 only has to compare itself to Cards 1 and 3. The relationship is symmetrical. If Card 0 matches Card 1 then certainly Card 1 matches Card 0. With a directed graph, I can connect the cards together to quickly traverse the pattern.
So how to represent in Python?
There are numerous graph libraries. There are numerous graph libraries in Python.
At first glance, a good data structure to represent the cards' grid would be a directed graph.
A directed graph would be simpler than an undirected graph. The compare only needs to work one way.
For example, Card 0 only has to compare itself to Cards 1 and 3. The relationship is symmetrical. If Card 0 matches Card 1 then certainly Card 1 matches Card 0. With a directed graph, I can connect the cards together to quickly traverse the pattern.
So how to represent in Python?
There are numerous graph libraries. There are numerous graph libraries in Python.
Tuesday, July 5, 2011
Vess Cola, Part 1.
When I was growing up, I had a wonderful window+grandmotherly next door neighbor--Gerri (Jeri? Geraldine?) LeVeaux. She was the kind of next door neighbor who always had cookies for us kids and paid us $1 to mow her tiny lawn even though she was perfectly able to mow it herself.
Some time, when I was a kid, she gave me a puzzle she said belonged to her son. I became the proud caretaker of the Vess Puzzle.
Hmmm... I need to scan the back of the pieces, too.
I've long since lost the envelope the puzzle came in. But the puzzle is simple enough. Match up the same color top and bottom of the Vess Cola bottles.
During college, I'd get the puzzle out of my desk, solve it to avoid doing homework.
A little while ago, I started talking with my father-in-law about puzzles. I hadn't played with Vess for quite a while so I brought out the puzzle. And couldn't solve it.
Being a programmer nerd, I thought Vess would be a fun programming problem. So I set about solving the puzzle with a Python script.
Some time, when I was a kid, she gave me a puzzle she said belonged to her son. I became the proud caretaker of the Vess Puzzle.
Hmmm... I need to scan the back of the pieces, too.
I've long since lost the envelope the puzzle came in. But the puzzle is simple enough. Match up the same color top and bottom of the Vess Cola bottles.
During college, I'd get the puzzle out of my desk, solve it to avoid doing homework.
A little while ago, I started talking with my father-in-law about puzzles. I hadn't played with Vess for quite a while so I brought out the puzzle. And couldn't solve it.
Being a programmer nerd, I thought Vess would be a fun programming problem. So I set about solving the puzzle with a Python script.
Installing 32-bit Support to 64-bit Ubuntu
If you are running Ubuntu 64-bit, install the ia32-libs
# sudo apt-get install ia32-libs
(Or use Synaptic.)
References:
http://ubuntuforums.org/showthread.php?t=720732
http://www.debian-administration.org/articles/534
# sudo apt-get install ia32-libs
(Or use Synaptic.)
References:
http://ubuntuforums.org/showthread.php?t=720732
http://www.debian-administration.org/articles/534
Friday, May 20, 2011
Linux USB Printer/Scanner Hacks.
I develop scanner/printer firmware. I develop under Linux.
Here are a few handy things I use to make my life easier.
Disable the Ubuntu “New Printer” dialog.
From Jeremy Ward, a coworker.
“One issue I was having was the printer driver install prompts displayed when plugging the dev board in/loading code on the dev board. I remember you mentioning that you had the same problem on Ubuntu. I was able to fix this issue by modifying the rules in /lib/udev/rules.d/70-printers.rules. I commented out all of the rules since that is what tells the system to launch the prompts. I don’t think there are any negative consequences from doing so.”
Allow user read/write to /dev/usb/lp*.
Add yourself to the ‘lp’ group with usermod. See usermod(8) man page.
Fedora : run system-config-users script (tested on FC14)
Ubuntu 11.04 : (from Desktop) System -> Administration -> Users and Groups
Allow user to scan without using root.
Either of the following methods should work. The following examples assume a USB VID of 0×8086 and USB PID of 0×1234.
From Eric Huang, a coworker.
- Add a new file called /etc/udev/rules.d/mrvl-printer.rules
- Add a line to the new file:
ATTRS{idVendor}==”8086” MODE:=”0666”
From David Poole.
- Edit /etc/udev/rules.d/40-libsane.d
- Add the following before the first ATTRS{idVendor}:
ATTRS{idVendor}==”8086″, ATTRS{idProduct}==”1234″, ENV{libsane_matched}=”yes”
I've also found being logged in to the console (the PC itself) allows me to scan on Fedora. There is some magic going on in udev where, if the user is on the console, access to the USB devices is allowed.
Here are a few handy things I use to make my life easier.
Disable the Ubuntu “New Printer” dialog.
From Jeremy Ward, a coworker.
“One issue I was having was the printer driver install prompts displayed when plugging the dev board in/loading code on the dev board. I remember you mentioning that you had the same problem on Ubuntu. I was able to fix this issue by modifying the rules in /lib/udev/rules.d/70-printers.rules. I commented out all of the rules since that is what tells the system to launch the prompts. I don’t think there are any negative consequences from doing so.”
Allow user read/write to /dev/usb/lp*.
Add yourself to the ‘lp’ group with usermod. See usermod(8) man page.
Fedora : run system-config-users script (tested on FC14)
Ubuntu 11.04 : (from Desktop) System -> Administration -> Users and Groups
Allow user to scan without using root.
Either of the following methods should work. The following examples assume a USB VID of 0×8086 and USB PID of 0×1234.
From Eric Huang, a coworker.
- Add a new file called /etc/udev/rules.d/mrvl-printer.rules
- Add a line to the new file:
ATTRS{idVendor}==”8086” MODE:=”0666”
From David Poole.
- Edit /etc/udev/rules.d/40-libsane.d
- Add the following before the first ATTRS{idVendor}:
ATTRS{idVendor}==”8086″, ATTRS{idProduct}==”1234″, ENV{libsane_matched}=”yes”
I've also found being logged in to the console (the PC itself) allows me to scan on Fedora. There is some magic going on in udev where, if the user is on the console, access to the USB devices is allowed.
Tuesday, March 15, 2011
Installing 32-bit Support to 64-bit Fedora 14
I'm moving to a new Linux build box. My original Linux box is a 32-bit Fedora FC14. My new Linux box is a 64-bit Fedora FC14.
Our compiler toolchain is a 32-bit app. The compiler didn't run on the new box, giving a cryptic error about /ld/ld-linux.so.2
Dug around Google. There are two postfixes (?) on FC14 packages: .i686 and .x86_64 (FC13 used .i586).
Short story: as root,
rpm -i bzip2-libs.i686
The dependency pulled in the 32-bit glibc. Probably could have installed just glibc.i686
The two glibc versions are installable side-by-side.
Our compiler toolchain is a 32-bit app. The compiler didn't run on the new box, giving a cryptic error about /ld/ld-linux.so.2
Dug around Google. There are two postfixes (?) on FC14 packages: .i686 and .x86_64 (FC13 used .i586).
Short story: as root,
rpm -i bzip2-libs.i686
The dependency pulled in the 32-bit glibc. Probably could have installed just glibc.i686
The two glibc versions are installable side-by-side.
Tuesday, March 1, 2011
Products I've Worked on.
HP LaserJet m1005. First scanner/copier.
HP LaserJet m1120. First network scan.
HP LaserJet m1319. First ADF, stepper motor.
HP LaserJet m1130. Low memory. Digital sensor.
HP LaserJet m1212nf. First combo ADF,flatbed. Digital sensor.
HP LaserJet m1120. First network scan.
HP LaserJet m1319. First ADF, stepper motor.
HP LaserJet m1130. Low memory. Digital sensor.
HP LaserJet m1212nf. First combo ADF,flatbed. Digital sensor.
Subscribe to:
Posts (Atom)