Icosagon Coloring

There are exactly 13 different ways to color each side of a regular hexagon either red or blue (where rotations or reflections of the same pattern are not considered a different way):

Using the same rules as above, use a computer program to find the number of different ways to color each side of regular 20-gon with just two different colors.


The answer is 27012.

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.

3 solutions

Mark Hennings
Jun 4, 2020

This is really an Algebra question, since it can be solved by a simple application of Burnside's Lemma : if a finite group G G acts on a finite set X X , then the number of orbits of this group action is equal to 1 G g G F X ( g ) \frac{1}{|G|}\sum_{g \in G}|F_X(g)| where F X ( g ) = { x X : g x = x } F_X(g) \; = \; \{ x \in X \,:\, g \cdot x = x \} is the set of elements of X X fixed by the group element g g .

In this case, let X X be the collection of 2 20 2^{20} different 2 2 -colourings of an icosagon, and let the dihedral group D 40 D_{40} , the full symmetry group of the icosagon, act on X X by performing the relevant rotation or reflection to any 2 2 -colouring. Running through the various elements of D 40 D_{40} :

  • There is 1 1 identity element, which fixes all elements of X X . Thus F X ( g ) = 2 20 |F_X(g)| = 2^{20} in this case.
  • There are 8 8 rotations of order 20 20 . The 2 2 -colourings that are fixed by such rotations are the ones where all sides have the same colour, and so F X ( g ) = 2 |F_X(g)| = 2 in these cases.
  • There are 4 4 rotations of order 10 10 . The 2 2 -colourings that are fixed by such rotations are the ones where alternate sides have the same colour, and so F X ( g ) = 2 2 |F_X(g)| = 2^2 in these cases.
  • There are 4 4 rotations of order 5 5 . The 2 2 -colourings that are fixed by such rotations are the ones where every fourth side has the same colour, and so F X ( g ) = 2 4 |F_X(g)| = 2^4 in these cases.
  • There are 2 2 rotations of order 4 4 . The 2 2 -colourings that are fixed by such rotations are the ones where every fifth side has the same colour, and so F X ( g ) = 2 5 |F_X(g)| = 2^5 in these cases.
  • There is 1 1 rotation of order 2 2 . The 2 2 -colourings that are fixed by this rotation are the ones where every tenth side has the same colour, and so F X ( g ) = 2 10 |F_X(g)| = 2^{10} in this case.
  • There are 10 10 reflections in axes through a pair of opposite vertices. There are 2 10 2^{10} 2 2 -colourings fixed by such a reflection.
  • There are 10 10 reflections in axes through the midpoints of a pair of opposite edges. There are 2 11 2^{11} 2 2 -colourings fixed by such a reflection.

Thus the total number of orbits is 1 × 2 20 + 8 × 2 + 4 × 2 2 + 4 × 2 4 + 2 × 2 5 + 1 × 2 10 + 10 × 2 10 + 10 × 2 11 40 = 27012 \frac{1 \times 2^{20} + 8 \times 2 + 4 \times 2^2 + 4 \times 2^4 + 2 \times 2^5 + 1 \times 2^{10} + 10 \times 2^{10} + 10 \times 2^{11}}{40} = \boxed{27012}


Indeeed, a generalisation of this argument shows us that the number of distinct 2 2 -colourings of a regular n n -gon is 1 2 n d n φ ( n d ) 2 d + 3 4 × 2 1 2 n \frac{1}{2n}\sum_{d|n} \varphi\big(\tfrac{n}{d}\big)2^d + \tfrac34 \times 2^{\frac12n} when n n is even, and 1 2 n d n φ ( n d ) 2 d + 2 1 2 ( n 1 ) \frac{1}{2n}\sum_{d|n}\varphi\big(\tfrac{n}{d}\big)2^d + 2^{\frac{1}{2}(n-1)} when n n is odd. The difference between these formulae results from the fact that there is only one type of reflection when n n is odd, as opposed to the two types of reflection that occur when n n is even.

Hi Mark, your explanation is fantastic but it seems very advanced. Can you please explain me in simple terms? This is problem is just fascinating and I am trying since a long time but couldn't get to the solution. Help will be very much appreciated. Thanks a lot in advance.

Mahdi Raza - 1 year ago

Log in to reply

I am sorry, but it is not possible to explain this proof unless you have studied some Group Theory, which most people do not do much of until they reach university. If you are interested, you could follow the link to the Brilliant wiki on Burnside's Lemma.

The only low-level proof that I can think of would be to write a suitable computer programme to find all 27012 colourings.

Mark Hennings - 1 year ago

Log in to reply

Sure, that's completely fine Mark. I opened the link but the proof is a bit more complex than I had thought of. I will look into a separate method or learn this later. Thanks for the reply!

Mahdi Raza - 1 year ago

Hi @Mahdi Raza , take a look at this link (https://m.youtube.com/watch?v=VOrVMQjQpGg) to get a good grasp of Burnside’s Lemma without any prerequisites ;)

Vedant Saini - 1 year ago

Log in to reply

Thank you for sharing Vedant, very very interesting video. I'll have to watch part 2 and 3. Thanks again!!

Mahdi Raza - 1 year ago

You’re welcome!

Vedant Saini - 1 year ago
David Vreken
Jun 6, 2020

The following python computer program goes through each possible coloring sequence ( 2 20 2^{20} of them, represented in binary notation) and uses a 2 20 2^{20} boolean item list u u to count them. If the sequence's corresponding item in u u is false, it hasn't been counted yet, so count it and then make that item in u u true and every rotation and reflection item in u u true as well.

After running the program, we find that the number of ways to color a regular icosagon with only two colors (where rotations or reflections of the same pattern are not considered a different way) is 27012 \boxed{27012} .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Polygon Coloring
# Python

# Function that converts a decimal number
#  to a binary number.
def dec_to_bin(n):
    bstr = ""
    while n:
        bstr += str(int(n % 2))
        n = int(n / 2)
    if bstr == "":
        b = 0
    else:
        b = int(bstr[::-1])
    return b

# Function that converts a binary number
#  to a decimal number.
def bin_to_dec(n):
    r = str(n)[::-1]
    d = 0
    for a in range(0, len(r)):
        d += (int(r[a]) * 2 ** a)
    return d

# Function that finds the number of ways
#  to color a regular polygon with n sides
#  with only two colors (without rotations
#  or reflections).
def polycolor(n):
    total = 0
    # u is a list of True/False values, where
    #  each index number, when converted to binary,
    #  corresponds to a coloring pattern.
    #  Each item in u turns to True when its
    #  color sequence (or rotation or reflection
    #  of that color sequence) is counted.
    u = []
    for a in range(0, 2 ** n):
        u.append(False)
    # Go through each possible coloring sequence
    #  and compare it to u to see if it is counted
    #  already.  If not, add 1 to the total and
    #  turn the u index to True, as well as all
    #  the rotations and reflections of that 
    #  coloring sequence.
    for a in range(0, 2 ** n):
        if not u[a]:
            seq = str(dec_to_bin(a)).zfill(n)
            total += 1
            s = seq + seq
            r = s[::-1]
            for b in range(0, n):
                u[bin_to_dec(s[b:b + n])] = True
                u[bin_to_dec(r[b:b + n])] = True
    # Return the total number.
    return total

# Find and display the number of ways to color
#  a regular icosagon with only two colors (without
#  rotations or reflections).
print(polycolor(20))

hi @David Vreken would you look at my code and tell me why it is so slow

Sahil Goyat - 11 months, 2 weeks ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from itertools import product          
def id(l):
    j=list(l)
    n=0
    for i in range(0,len(l)):
        k=list(j)
        m=max(int(''.join(k)),int(''.join(k[::-1])))
        if m>n:
            n=m
        j.insert(0,j.pop())
    return n
l=[]        
for i in product(['1','0'],repeat=20):
    k=id(list(i))
    if k not in l:
        l+=[k]
print(len(l))

Sahil Goyat - 11 months, 2 weeks ago

Log in to reply

I think your code is slower because you are using "id(list(i)) not in l" for each possibility, which is a time-consuming operation. (You may want to try something with boolean values like my program does instead.) Also, if "id(i)" is to be added, you are running the function "id" (unnecessarily) twice.

I also noticed that your program does not eliminate reflected repeats, just rotation repeats. For example, if you make "repeat = 6" in your code to try the given example in the problem, your program comes up with 14 instead of 13, because it incorrectly counts "110100" and "110010" as different possibilities.

David Vreken - 11 months, 2 weeks ago

Log in to reply

thanks i corrected the reflection mistake

Sahil Goyat - 11 months, 2 weeks ago
Jon Haussmann
Jun 4, 2020

Nice find! The wolfram link references sequence A000029 which gives the answer.

David Vreken - 1 year ago

Yes, great connection!!

Mahdi Raza - 1 year ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...