I was writing a C# class library to manage finite groups. A group is a set G of elements with a defined binary operation *, where:
a * b is in G (closure)
a * (b * c) = (a * b) * c (associative)
a * a’ = e (inverse and identity)
a * e = e * a (identity)
The solution code is in my AjCodeKata Google Project, under trunk/AjGroups:
The key interfaces are:
IElement has a method Multiply, that receives another IElement and returns the result IElement. IElement.Order is the number of elements to be multiplied to get the identity:
a * a * a ….. * a = e
IGroup.Elements is the collection of IElements that are the elements of the group. IGroup.Order is the count of elements.
There are two implementations of that interfaces: one based on permutations, another based on named elements (such “a”, “e”) and a table describing their multiplications.
There are methods to:
– Get the subgroups of a group
– Get the normal subgroups of a group
– Answer if two groups are isomorphic
I followed TDD ideas during development. All tests in green:
Good code coverage:
I should make some refactoring, but the project is taking form. I will write posts describing the permutation implementation, and the abstract elements implementation.