sleeping baby in a baby blanket

I’m scheduled to return to work this week, which makes it the perfect time to pick up another project (not). Nonetheless, I’ve been wanting to knit something for Aurelio for some time, and Ravelry’s declaration that they won’t steer away from “political knits” inspired me to go check out some patterns.

I found a simple baby blanket with a repeating pattern that adds some lacy details — baby loves this because he can stick his lil fingers in the holes. Here’s the pattern:

CO 107 st
Row 1: knit
Row 2: purl (and all even rows)
Row 3: k3, * k2tog, yo, k2 *
Row 5: knit
Row 7: k1, * k2tog, yo, k2 *, k2
Finish with row 1 or 5.

The elements in * are repeated for the remaining stitches in the row.

Now, I want my blanket to be smaller than the pattern. A mini-blanket. But the thing with knitting is you can’t just pick an arbitrary number to cast on or else you’ll break the pattern and wind up ☠️. So how do I figure out how many stitches to cast on?

Option 1: Overengineer a ruby solution to visualize the pattern, then guess and check at cast-on numbers to figure out which ones work.

What an EXCELLENT idea. Let’s do just that.

I started with some nested functions, like this:

…then realized I was breaking the rule of DRY (Don’t Repeat Yourself). Let’s get a bit more object-oriented, shall we?

that’s better, now I don’t need to pass on the width to all those functions, I can use the object’s instance-accessible @width property.

Coded correctly, the pattern passes with the default cast-on width, and breaks when a width breaks the pattern.


Doesn’t work:

I used the guess and check method to find a variety of cast-on options that don’t break the code, including 107, 99, 87, 75, 63, 51, 55, 7, 11. What do all these numbers have in common?  And how can we identify them without testing via an elaborate visual chart?

There must be a more mathy way to solve this, right?

Option 2: Ask Mary’s Mom

My mom is a skilled seamstress and knitter/crocheter, not to mention a Mensan, so I knew she would know how to reduce a pattern without all that hub-bub above.  I sent her the pattern and asked her what my cast-on options are. She said:

Looks to me like the pattern is just 4 stitches +3 on the edges, so you could cast on 7 or 11 or 15 or 51.

4 and 3… going back to our tested numbers, we find that they are congruent modulo 4, meaning they give the same remainder (3) when divided by that number. Put another way, any multiple of 4 (the pattern), plus 3 (the stitches on either side), will work (4 * 10 + 3 = 43 = works).

Don’t forget to remove the blanket from the crib once baby falls asleep.

If you all have any additional knitting or math questions for my mom I am happy to pass them along.