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 parallel stitches. With the black string tied around the sewing needle and button correctly positioned, he sewed the button as follows:
If T = 1 0 , 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:
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.
For the problem, visualize two parallel sets as two separate containers, containing a number of items (visualized as number of switches). Let
Without loss of generality, we can assume that the first stitch included in P 2 is either the diagonal or orthogonal stitch. Thus, ( 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 )
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
Then, since there is at least 1 swap-insert that must occur in P 2 , 1 0 ≤ n 2 + n 3 ≤ n 2 + n 3 − 1 ≤ 2 T − 1 ≤ 2 T − 2
Noting that P 1 is the first to receive an insert,
Parametrizing,
So since
The total different ways to stitch a button in terms of T is 8 ⋅ 2 2 T − 1 + 8 odd ∑ + 8 even ∑ = 4 ( 2 2 T + n = 1 ∑ T − 1 2 2 n ( n − 1 T − 1 ) 2 n 2 T − n )
where the bounds of k 1 and k 2 are made to be consistent. For the answer, if T = 1 0 , then we have 2 3 0 9 2 3 6 5 9 2 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.
Log in to reply
Well explained, but the 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 , where χ ( 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.
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 ?
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.
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.
Log in to reply
It's good that you shared the computer science approach. :)
Log in to reply
@Michael Huang – It's probably the one that requires the less thinking (for the human being)
Log in to reply
@Pierre Stöber – Since each sewing approach is unique, combinatorics can easily be applied.
Problem Loading...
Note Loading...
Set Loading...
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 = 3 2 ways of stitching it; and in an arrangement with k runs, there would be 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 be the number of runs of consecutive stitches. (In the above example, k would be 5 .) If k is even, then we will have 2 k Left runs and 2 k Right runs; on the other hand, if k is odd, we will have 2 k + 1 Left runs and 2 k − 1 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: ⌊ 2 k + 1 ⌋ Left runs and ⌊ 2 k ⌋ Right runs.
Consider the ten Left stitches. We have to split them into ⌊ 2 k + 1 ⌋ non-empty groups. Recall that n identical objects can be partitioned into k non-empty groups in ( k − 1 n − 1 ) ways. [Quick explanation: we'd need k − 1 dividers, each of which can be placed at one of the n − 1 positions between the objects, no more than one divider per position.]
Then the ten Left stitches can be partitioned in
( ⌊ 2 k + 1 ⌋ − 1 1 0 − 1 )
ways. Similarly the ten Right stitches can be partioned in
( ⌊ 2 k ⌋ − 1 1 0 − 1 )
ways. These two binomials can be simplified to
( ⌊ 2 k − 1 ⌋ 9 ) and ( ⌊ 2 k − 2 ⌋ 9 )
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
( ⌊ 2 k − 1 ⌋ 9 ) ( ⌊ 2 k − 2 ⌋ 9 ) 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 ∑ 2 0 ( ⌊ 2 k − 1 ⌋ 9 ) ( ⌊ 2 k − 2 ⌋ 9 ) 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 5 7 7 3 0 9 1 4 8 × 4 = 2 3 0 9 2 3 6 5 9 2