Category Archives: Python

Python Performance Tuning (con’t)

Let’s continue tuning our KenKen puzzle solver. When we left off yesterday, we’d cut execution time by 30% with a one-line change to the program, but there is still much room for improvement.

Posted in Projects, Python | Comments Off

Python Performance Tuning

Having just built a solver for KenKen puzzles, this is a good opportunity to take a look at performance tuning in Python. Today we’ll look at some basic instrumentation, and begin searching for bottlenecks in the solver.

Posted in Projects, Python | Comments Off

Solver for KenKen puzzles (Search)

Today we complete the first version of our solver for KenKen puzzles. Previously we’ve defined constraint classes, input/output functions, and data structures; all that remains is to write the search and propagation code. Once again, this is all based on … Continue reading

Posted in Projects, Python | Comments Off

Solver for KenKen puzzles (Representation)

One of the biggest differences between KenKen puzzles and Sudoku puzzles is that the former are harder to represent compactly. Sudoku puzzles can be represented as a simple string of numbers, but the 2-dimensional cages of KenKen puzzles seem to … Continue reading

Posted in Projects, Python | Comments Off

Solver for KenKen puzzles (Constraints)

Today I’m going to show the Constraint implementation for a KenKen solver I’m building. This code will cover all the rules of the KenKen game, and will shortly be used in a constraint propogation and search algorithm. It contains several … Continue reading

Posted in Projects, Python | Comments Off

Solver for KenKen puzzles (Constraint design)

Following up on yesterday’s post, I’d like to get started on the construction of a solver for KenKen puzzles, using the same basic constraint-propogation-and-search approach that Norvig used in his Sudoku solver. I’m going to begin with a discussion of … Continue reading

Posted in Projects, Python | Comments Off

Details Matter

I was looking at Norvig’s Sudoku solver the other day, and suddenly understood a design choice that had previously struck me as bizarre. I think it’s a neat example of how small, seemingly arbitrary things can make your programming either … Continue reading

Posted in Python | Comments Off

Python Puzzle

Pedram Amini has got a pretty neat post up on reverse engineering the protocol for a USB device. If you haven’t seen it yet (it was linked from Slashdot) it’s worth reading. However, he includes some Python code which features … Continue reading

Posted in Python, Reverse Engineering | Comments Off

Generating HTML from Python

Occasionally I will write scripts which generate HTML documents. I understand the view that HTML is “object code”, and that its formatting doesn’t matter, but I’ve never been completely able to adopt that position. As a result, I usually try … Continue reading

Posted in Planet Microsoft, Python, UNIX, Web stuff | Comments Off

Disassembler (Odds and Ends)

This week, I post some remarks following up on the just-concluded disassembler tutorial; there are always a few loose ends to tie up, and I wanted to clarify or expand on: The opcode map Addressing Demo code Hardening

Posted in Planet Microsoft, Projects, Python, Reverse Engineering | Comments Off