title: Determine if (*,G) forms an associative group in group theory
body: <p>Lets say I have a group G={a,b,e} where a,b are arbitrary elements and e denotes the neutral element. I came up with a certain Cayley table and want to verify that what I have done is right by checking the associativity. </p>
  
  <p>That means I want to check for arbitrary x,y,z in G that x(yz)=(xy)z, because by hand I would have to check 3*3*3 = 27 cases, which is just nuts. </p>
  
  <p>I didn't come far in my coding so far and I'd appreciate some hints or elegant ways how to approach this problem. I am a beginner at python but have a basic understanding of loops and functions.</p>
  
  <p><strong>My idea of the program</strong>: </p>
  
  <p>I define a function lets say group which takes as an input a string. I add the string by the .extend(string) function to certain list which allows me to analyze the given input one by one. </p>
  
  <p>Via an if statement lets say:</p>
  
  <pre><code>if checklist[0] == "a" and checklist[1] == "b":
      checklist.pop[0]
      checklist[0] = "e"
  </code></pre>
  
  <p>I could first drop the first entry of the list and then replace it by the desired new value. I did continue like that adding more and more if statements and at the end recursively called my function again and it would terminate if the length of my checklist is equal to 1. </p>
  
  <p>However this is not a very elegant code which also runs into problems with special cases. Hence I believe my effort was in vain and I ought to believe that there is a much simpler and more elegant solution to this problem. I hope you can help me guide me in the right direction to find it. </p>
  
  <hr>
  
  <p><strong>Code example</strong> (not complete but conceptual):</p>
  
  <pre><code>checklist = []
  
  def group(abc):
      if len(checklist) == 1:
          return checklist
      else:
          checklist.extend(abc)
          if (checklist[0] == "a" and checklist[1] == "a"):
              checklist.pop(0)
              checklist[0] = "b"
          if (checklist[0] == "a" and checklist[1] == "b"):
              checklist.pop(0)
              checklist[0] = "e"
          if (checklist[0] == "a" and checklist[1] == "e"):
              checklist.pop(0)
              checklist[0] = "a"
          if (checklist[0] == "b" and checklist[1] == "a"):
              checklist.pop(0)
              checklist[0] == "e"
          if (checklist[0] == "b" and checklist[1] == "b"):
              checklist.pop(0)
              checklist[0] = "a"
          if (checklist[0] == "b" and checklist[1] == "e"):
              checklist.pop(0)
              checklist[0] = "b"
          if (checklist[0] == "e" and checklist[1] == "a"):
              checklist.pop(0)
              checklist[0] = "a"
          if (checklist[0] == "e" and checklist[1] == "b"):
              checklist.pop(0)
              checklist[0] = "b"
          if (checklist[0] == "e" and checklist[1] == "e"):
              checklist.pop(0)
              checklist[0] = "e"
          group(checklist)
          return checklist
  </code></pre>