In the pattern lock system below,
For example, pattern #1 below is good.
Pattern #2 is invalid because it includes a cycle, as indicated by the red square. Pattern #3 is invalid because it contains an implicit cycle, i.e. the red segment must be traveled twice to go from the lower left corner to the lower right corner. Pattern #4 is invalid because a diagonal edge is used to connect 2 nodes.
So, how many different patterns can be generated for this system?
Bonus : What if using diagonal edges is allowed while intersections between 2 or more diagonal edges are prohibited. Can you find the number of different patterns in this case?
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.
I looked at it as patterns that are rotated and/or mirrored. I saw 3 distinct patterns that I call "G", 21 and "5", because that's what specific orientations of them look like.
"G" starts at the center point, moves to the right edge, then traverses around the edges clockwise, so it looks like a "G". It can be rotated into one of 4 different orientations and each of those can be mirrored into another 4 orientations, for a total of 8 different "G" forms.
"21" starts with the upper left corner, moves right 1, then down 1 to the center, left 1 to the left edge, down 1 to the bottom left corner, right 2 to the bottom right corner, then up 2 to the top right corner, so it looks like "21". Just as with "G" it can be rotated into one of 4 different orientations and each of those mirrored into another 4 orientations, for a total of 8 different "21" forms.
"5" starts at the upper right corner, moves left to the UL corner, goes down 1, over to the right edge, down 1 and over to the left corner, so it looks like a "5". It can be rotated into only one other orientation, i.e. by 90 degrees, as rotating by 180 yields the original form, and rotating by 270 degrees yields the 90 degree form. Each rotation can also be mirrored, making it look like a "2". This makes a total of 4 different "5" forms.
8 + 8 + 4 = 20....
Log in to reply
I was stuck on 24, until I read this. The 180 degree rotational symmetry got me
Is there a way of solving the problem purely combinatorially?
Log in to reply
@Rajdeep Ghosh , name the vertices like a b c d e f g h i
a,c,i,g are corners, b,f,h,d are mid-corners, e is center. In the final solution, exactly 2 of corners or center(a,c,i,g,e) have degree 1 and all the remaining vertices should have degree 2. so it should be 5c2 combinations (choose any 2 of 5) = 10 for each combination, you can draw 2 paths.so 10*2 = 20 different paths.
My solution is purely combinatorial.
Log in to reply
When I said ' purely combinatorial' I meant a solution without the graph theoretic elements as I'm new to it. Don't update your main solution, just explain the graph theoretic terms.
Log in to reply
@Rajdeep Ghosh – There is no graph theoretic term used in there. The only thing is probably "directed path" and "undirected path"; your pattern doesn't have any direction, so I put a direction on it (from some start point to some end point). "Path" is simply what you call pattern. The rest should be fully understandable even without knowledge of graph theory.
Log in to reply
@Ivan Koswara – Just one more left. Hamiltonian path.
Log in to reply
@Rajdeep Ghosh – Ah, right, whoops. Hamiltonian path means it visits every point exactly once (that is, without cycles), which is the first condition you listed.
Why is it not clarified in the question that the paths are not directional? I did have 40 as the answer, which was marked as incorrect. Surely if we are talking about a pattern lock directionality is important.
Log in to reply
I see nothing in the question to suggest orientation to be considered part of the pattern.
the answer is 20
Well by a bit of trial and error, one notices that only the corner point and the centre points can be used as start or end of a pattern. We cannot use the edge centre points. Now we can also conjecture that for every pair of such points, there exists exactly one path (This is simple enough to verify on paper, accounting for symmetry). So we have 5 points, of which we need to select two non-same points in order. Hence 5*4=20
For a purely undirected approach, consider the central point as our way to classify patterns. We can have a pattern where the center only has one edge connected to it. Said edge could be in any of four directions. Then outer boundary would missing exactly one edge at the point connected to the center, and there are two possibilities there. So there are eight patterns where the center is connected to the outer edge exactly once. Next, consider patterns where the center point is connected to two points on opposite sides of the square. This path could be horizontal or vertical, and in either case we could have the pattern oriented to an S shape to the curve or a Z shape (rotated appropriately). This gives four more patterns. Finally, the center point could connect with edges to two adjacent sides of the square. In this case, the corner meeting those two sides has to connect to one of the two edges, and either is a valid choice which forces the rest of the outside to be connected to the other edge. (See for example #1 in the question.) There are four pairs of adjacent sides with two orientations possible for each, making another 8 patterns. We have exhausted the possibilities and thus there are 8 + 4 + 8 = 20 patterns total.
Problem Loading...
Note Loading...
Set Loading...
This is equivalent to finding the number of Hamiltonian paths in a 3 × 3 grid graph. We will first find the number of directed paths; we'll simply divide by 2 to obtain the number of undirected paths (each path can be traversed in two directions).
First, color the points in a checker pattern, so the corners and the center are white, while the edge points are black. Then every edge in a path must connect two points of different colors, so the path alternates between colors. Since there are one more white point than black, the path must begin and end on a white point.
Now we simply count everything carefully. We'll divide into two cases:
Since there are 4 corner points, the corners contribute 32 paths in total. Adding the center point gives 40 directed paths, or 2 0 undirected paths.