Sewing Combinatorics

Handsome Brilli noticed that a button had fallen off from his black suit. As shown on the left, he decided to sew a spare button such that it shows a parallel arrangement, where each side consists of T T parallel stitches. With the black string tied around the sewing needle and button correctly positioned, he sewed the button as follows:

  1. From the bottom side, insert the needle into one of the 4 holes. Then, secure the button by inserting the needle into a different hole adjacent to the previous. These two holes are now inserted.
  2. Choose one of the 3 holes to insert. If the chosen hole is not yet inserted, form another stitch between two unconnected holes. Otherwise, form another parallel stitch between its respective holes. The diagram on the right illustrates all possible ways to stitch the bottom side from one hole to another.
  3. Repeat Step 2 until a pair of T T parallel stitches are formed.

If T = 10 T = 10 , what is the total possible ways (including 4 different initial inserts and 2 different arrangements) to sew a button from the start?

Details and Assumptions:

  • Neglect the thickness of the thread for this problem.
  • At the final step of sewing, the needle appears on the bottom side.


The answer is 2309236592.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Zico Quintina
Apr 14, 2018

To begin, note that we can make horizontal stitches (ten Top, ten Bottom) or vertical stitches (ten Left, ten Right), so there are four different positions for the first stitch. WLOG, assume that the stitches are vertical and that our first stitch is Left.

One possible arrangement of stitches by position is then LLLRRRRLLLLLRRRRRRLL. Note that in this arrangement, we have two choices of how to make the first Left stitch (from top to bottom or from bottom to top); however the next two Left stitches have to follow the same choice as the first Left stitch. When we switch to the Right for the fourth stitch, we again can choose the direction for that stitch (top to bottom or bottom to top) but after that the next three Right stitches must follow the same direction as the first Right.

Following this reasoning, it should be clear that we have a choice of two directions for the first stitch in each run of consecutive Left or Right stitches, but no choice for any subsequent stitches in the same run. (To clarify, the above arrangement would consist of a run of three Lefts, a run of four Rights, a run of five Lefts, a run of six Rights and finally a run of two Lefts.)

Thus the number of ways of sewing any particular arrangements depends on the number of runs of consecutive stitches on the same side. For the above arrangement, which consists of five runs, there would be 2 5 = 32 2^5 = 32 ways of stitching it; and in an arrangement with k k runs, there would be 2 k 2^k ways of stitching it. So we need to count the number of arrangements of Left and Right stitches for all possible number of runs of consecutive stitches.

Let k k be the number of runs of consecutive stitches. (In the above example, k k would be 5 5 .) If k k is even, then we will have k 2 \frac{k}{2} Left runs and k 2 \frac{k}{2} Right runs; on the other hand, if k k is odd, we will have k + 1 2 \frac{k+1}{2} Left runs and k 1 2 \frac{k-1}{2} Right runs (remember our initial assumption was we were starting with a Left stitch.) Using the floor function, we can write a single formula for each side: k + 1 2 \left\lfloor \frac{k+1}{2} \right\rfloor Left runs and k 2 \left\lfloor \frac{k}{2} \right\rfloor Right runs.

Consider the ten Left stitches. We have to split them into k + 1 2 \left\lfloor \frac{k+1}{2} \right\rfloor non-empty groups. Recall that n n identical objects can be partitioned into k k non-empty groups in ( n 1 k 1 ) \binom{n-1}{k-1} ways. [Quick explanation: we'd need k 1 k-1 dividers, each of which can be placed at one of the n 1 n-1 positions between the objects, no more than one divider per position.]

Then the ten Left stitches can be partitioned in

( 10 1 k + 1 2 1 ) \dbinom{10-1}{\left\lfloor \dfrac{k+1}{2} \right\rfloor-1}

ways. Similarly the ten Right stitches can be partioned in

( 10 1 k 2 1 ) \dbinom{10-1}{\left\lfloor \dfrac{k}{2} \right\rfloor-1}

ways. These two binomials can be simplified to

( 9 k 1 2 ) and ( 9 k 2 2 ) \dbinom{9}{\left\lfloor \dfrac{k-1}{2} \right\rfloor} \quad \text{and} \quad \dbinom{9}{\left\lfloor \dfrac{k-2}{2} \right\rfloor}

respectively. Thus, again keeping in mind we're starting with Left, the total number of ways to stitch an arrangement with k runs of consecutive stitches is

( 9 k 1 2 ) ( 9 k 2 2 ) 2 k \dbinom{9}{\left\lfloor \dfrac{k-1}{2} \right\rfloor} \dbinom{9}{\left\lfloor \dfrac{k-2}{2} \right\rfloor} 2^k

We need to sum this over all possible values of k; clearly the lowest number of runs is two (ten Left followed by ten Right) and the largest is twenty (alternating single Left and single Right stitches). Therefore the total number of ways of stitching vertical stitches starting with a Left is

k = 2 20 ( 9 k 1 2 ) ( 9 k 2 2 ) 2 k \displaystyle\sum_{k=2}^{20}\dbinom{9}{\left\lfloor \dfrac{k-1}{2} \right\rfloor} \dbinom{9}{\left\lfloor \dfrac{k-2}{2} \right\rfloor} 2^k

Unfortunately I have no idea how to compute this in any simple way, so I had to resort to brute force. I used Excel (!), below is a screengrab of the result.

Finally, we have to account for the four different positions for the first stitch, so our final answer is 577309148 × 4 = 2309236592 577309148 \times 4 = \boxed{2309236592}

Michael Huang
Apr 5, 2018

For the problem, visualize two parallel sets as two separate containers, containing a number of items (visualized as number of switches). Let

  • T T denote the number of top stitches;
  • n 1 n_1 denote the number of times inserted back at the same hole;
  • n 2 n_2 denote the number of inserts from forming the diagonal stitch;
  • n 3 n_3 denote the number of inserts from forming the orthogonal stitch; it is the stitch that is parallel to the previously formed parallel top stitch;
  • P 1 P_1 denote the set, where the 1st top stitch is formed
  • P 2 P_2 denote the second set
  • s 1 s_1 denote the number of self-inserts in P 1 P_1 , whereas s 2 s_2 in P 2 P_2
  • n sw 1 n_{\text{sw}_1} denote the number of swapping times to P 1 P_1 , whereas n sw 2 n_{\text{sw}_2} denotes the number of swapping times to P 2 P_2 (excluding the first swap to P 2 P_2 )

Without loss of generality, we can assume that the first stitch included in P 2 P_2 is either the diagonal or orthogonal stitch. Thus, ( T 1 ) (T - 1) more inserts must occur each on both sets. In this case, s 1 + n sw 1 = s 2 + n sw 2 = ( T 1 ) s_1 + n_{\text{sw}_1} = s_2 + n_{\text{sw}_2} = (T - 1)

Since the total number of inserts is the total number of top stitches formed, excluding the 1st, this can be expressed as n 1 + n 2 + n 3 = 2 ( T 1 ) 1 = 2 T 1 n_1 + n_2 + n_3 = 2(T - 1) - 1 = 2T - 1

Then, since there is at least 1 1 swap-insert that must occur in P 2 P_2 , 1 n 2 + n 3 2 T 1 0 n 2 + n 3 1 2 T 2 \begin{array}{rrl} 1 &\leq n_2 + n_3 &\leq 2T - 1\\ 0 &\leq n_2 + n_3 - 1 &\leq 2T - 2 \end{array}

Noting that P 1 P_1 is the first to receive an insert,

  • P 1 P_1 contains n 2 + n 3 + 1 2 \left\lceil \dfrac{n_2 + n_3 + 1}{2}\right\rceil switch-inserts
  • P 2 P_2 contains n 2 + n 3 + 1 2 \left\lfloor \dfrac{n_2 + n_3 + 1}{2}\right\rfloor switch-inserts

Parametrizing,

  • For n 2 + n 3 = 2 k 1 1 n_2 + n_3 = 2k_1 - 1 odd, where k 1 N k_1 \in \mathbb{N} , n sw 1 = n sw 2 = ( k 1 1 ) n_{\text{sw}_1} = n_{\text{sw}_2} = (k_1 - 1)
  • For n 2 + n 3 = 2 k 2 n_2 + n_3 = 2k_2 even, where k 2 N k_2 \in \mathbb{N} , n sw 1 = k 2 n_{\text{sw}_1} = k_2 and n sw 2 = ( k 2 1 ) n_{\text{sw}_2} = (k_2 - 1)

So since

  • The inserts for both two top stacks can be arranged in any order, so for P 1 P_1 we have ( T 1 n sw 1 ) \dbinom{T - 1}{n_{\text{sw}_1}} and for P 2 P_2 we have ( T 1 n sw 2 ) \dbinom{T - 1}{n_{\text{sw}_2}}
  • There are two different ways to identify each switch-insert
  • There are 4 different holes to insert and 2 different arrangements to sew in the beginning

The total different ways to stitch a button in terms of T T is 8 2 2 T 1 + 8 odd + 8 even = 4 ( 2 2 T + n = 1 T 1 2 2 n ( T 1 n 1 ) 2 2 T n n ) 8 \cdot 2^{2T - 1} + 8 \sum_{\text{odd}} + 8 \sum_{\text{even}} = 4\left(2^{2T} + \sum\limits_{n = 1}^{T - 1} 2^{2n}\dbinom{T - 1}{n - 1}^2 \dfrac{2T - n}{n}\right)

where the bounds of k 1 k_1 and k 2 k_2 are made to be consistent. For the answer, if T = 10 T = 10 , then we have 2309236592 \boxed{2309236592} different ways.

I came up with a similar (maybe simpler) visualization of this problem (sorry no illustration). I will try to give you an idea of my reasoning without necessarily making a lot of calculations.

To start, let's name the 4 holes 1-2-3-4. For now, we'll assume that 1 is paired with 2, and 3 is paired with 4 and the configuration of the holes looks like this:

1 3

2 4

Now imagine a 10x10 grid. Each minimal path from the bottom left corner (0,0) to the top right corner (10,10) represents a certain number (how many ?) of ways of making the 20 stitches. Going right represents a stitch between the first two holes (from hole 1 to 2 or from hole 2 to 1) and going up represents a stitch between the two other holes (from hole 3 to 4 or from hole 4 to 3). If you are making more than one step in the same direction, the orientation of the stitch remains the same (a stitch from hole 2 to hole 1 cannot follow one from hole 1 to hole 2, the same goes for holes 3 and 4 ).

To determine the number of possible ways for each path, you have to count the numbers of (straights) segments of each path. Each new segment represents a binary choice (the orientation of the stitch when you change side). Example: https://goopics.net/i/Nd0lZ this path has 6 segments and you can make 2^6=64 different stitch patterns using it. Thus comes the important deduction:

You sum 2^(number of segments per path) over the number of paths to get the number of possible ways to make the 20 stitches.

This sum is pretty easy if you separate the different paths according to the number of segments.(you just have to choose a certain number of "inflection" points depending on the number of segments). The sum ends up being similar to yours. Let's not forget to multiple everything by 2 at the end because we assumed the stitches at the top of the button were only vertical, though they can be horizontal as well.

I hope I made myself (a little bit) clear. Although I solved the problem by writing a program using recursive trees (4 lines of code), I thought this was a pretty neat visualization of the problem. Btw I found out that it was related to another problem: https://oeis.org/A051708 with those values being 1/8th of your problem. Although it's worth mentioning that this correspondance only works when the number of stitches on both sides (and both sides of the board in the second case) are equal.

Pierre Stöber - 3 years, 2 months ago

Log in to reply

Well explained, but the 2 2 exponent is derived from forming the bottom stitch between two opposite sides. Since there are 3 different options to choose from, either we have a 2-vertex graph or two different 3-vertex tree graphs. The endpoints of these graphs determine the resulting adjacency holes between two steps. The "switch" occurs if any of the 3-vertex tree graphs share with two vertices within one set. Do note that not all steps consist of diagonal and orthogonal bottom stitches. This is where summation plays the role.

Or you can also consider coloring method for this problem. The cycle graph of 4 vertices C 4 C_4 , where χ ( C 4 ) = 2 \chi (C_4) = 2 . This shows that 2 colors are used.

It seems that my solution is oversimplified, but that is the best I can think of. It would be interesting if there is an "overkill" solution posted for this problem.

Michael Huang - 3 years, 2 months ago

Log in to reply

I think you meant "two different 2 vertex graphs or a 3 vertex tree graph". It's interesting to see that it can be approached differently while still being the same problem. I like visual approches the best because it allows you to connect seemingly different problems. Anyway that was a very good puzzle. How did you come up with it ?

Pierre Stöber - 3 years, 2 months ago

Log in to reply

@Pierre Stöber by the way there is also https://oeis.org/A085363 that is related to this problem. It's basically the same problem, whereas https://oeis.org/A051708 was probably only a coincidence. Alright I will stop commenting now.

Pierre Stöber - 3 years, 2 months ago

My code in c++(if you are interested):

howmuch(int x,int y) {if(x<0 or y<0) return 0;

if(x==0 and y==0) return 1;

return howmuch(x-1,y)+2*howmuch(y-1,x);}

the answer to the problem is 8*howmuch(9,10). Just to clarify howmuch(x,y) outputs the number of possible ways to make a total of x stitches between holes 1 and 2 (independent of direction) and y stitches between holes 3 and 4 (independent of direction), knowing that you first stitch goes from hole 1 to 2 (it must because it's fixed but it's not included in the input).

In this situation you have 9 stitches left to do between between holes 1 and 2, and 10 between 3 and 4. Knowing that there are (4 pair of points * 2 orientations=) 8 ways to make the first stitch. you get this result.

Pierre Stöber - 3 years, 2 months ago

Log in to reply

It's good that you shared the computer science approach. :)

Michael Huang - 3 years, 2 months ago

Log in to reply

@Michael Huang It's probably the one that requires the less thinking (for the human being)

Pierre Stöber - 3 years, 2 months ago

Log in to reply

@Pierre Stöber Since each sewing approach is unique, combinatorics can easily be applied.

Michael Huang - 3 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...