Friday, October 1, 2010

Algorithms, Reverse Engineering, and Crochet

Sing along: One of these things is not like the other. One of these things just doesn't belong…



Actually, not really. These things can all go together: algorithms, reverse engineering, and crochet. I've been crocheting since I was so young I don't remember not crocheting. My Mimi (what I call my grandmother) taught me. There exist crochet patterns you can buy on paper or find online, but she doesn't know how to read them. I've read one pattern. It was for a doily I made in high school. So, how did Mimi and I know what to do when crocheting the rest of our lives? Reverse engineering!


Mimi had a big clear plastic bin in her nightstand full of samples of crochet. They were usually about 10x20cm or 5x8in and done in whatever scraps of yarn she had sitting around, so it was a very colourful pile. Each one had a different pattern in it. She was always fond of the seashell patterns though. There were others that looked like little rows of pillars on a Greek building and she had one very complicated one that sort of made a starburst shape within itself. If she wanted a certain effect, she'd just dig up her sample, poke at it a bit and look really close, and then copy how it was done. Maybe she'd add a few extra stitches to make the seashells wider or something, but to her a finished example was better than written instructions. I didn't learn the term until a few years ago, but poking at things to see how they work, then using that knowledge to go make some more? That's reverse engineering.


I've had a few people express surprise at someone being into artsy right-brain things and computery left-brain things. One was in the car on the way to Southeast LinuxFest, as I was sitting in the back crocheting. I responded by reciting the pattern of what I was doing as a bunch of nested for-loops. Hey, it's an algorithm. Here's a picture of me crocheting at the speakers dinner. I was making a pink snood based on the white one I'm wearing in the photo. I figured I'd be asked about being Amish less frequently if I had a pink one.



Dustin wrote a couple weeks ago about teaching his wife to code. She also crochets. I mentioned in his comments that reverse engineering and algorithms are a big part of crochet too. To demonstrate, today I finished crocheting a scarf. Here's the algorithm, in Python:


#!/usr/bin/python
for i in range(20):
print "ch",

for i in range(6):
for j in range(2):
print "ch",
print "\nnext: "
for j in range(20):
print "s",
print "ch",
for j in range(10):
for k in range(3):
print "ch",
print "\nnext: "
for k in range(10):
print "d ch",
for j in range(2):
print "ch",
print "\nnext: "
for k in range(20):
print "s",

Key:




  • ch: chain

  • d: double crochet

  • s: single crochet


Thanks to Kim Kirkland for correcting my long-hand stitch names into the standard abbreviations.



PS: the scarf is aubergine ;-)

No comments:

Post a Comment