Beta
Is it a group? (Group theory, Abstract algebra)
30ewanmurr
Loading description...
Mathematics
Algorithms
View
Career Accelerator
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
A useful fact: It is sufficient to check if there exist a left neutral element "e" (ie. e * g == g for all g) and each element "g" has a left inverse (ie. there is "h" such that h * g == e). Then, under associativity and using a few tricky comparisons, we can prove that any left inverse is also a right inverse, "e" is (two-sided) neutral element, from which the uniqeness of "e" and all inverses follows.
I really enjoyed this one. It'd be nice to have similar other ones for different algebraic entities (I've never seen before). Well maybe it would be nice to make them myself if they don't exist....
This comment has been hidden.
It would be nice if you give information about the set and the binary operation used for a test, so that the user can debug more easily.
Shouldn't
group_set
be aset
rather than alist
? Otherwise there can be duplicate elements.Is it really needed to make a class just to check one thing? A class that serves no purpose but to call a single function using the constructor parameters as its parameters is meaningless. You might as well just turn it into a function
is_group(group_set, binary_operation)
.(Marking this an issue since inevitably every other language translation will pick this up and it'll be very messy)
Hi, I was thinking I might make it into a series of kata where you add more functions one at a time if this one went down well. I saw that in a Morse code kata and liked the idea. There are other interesting properties of groups that could be interesting to implement like finding subgroups or proving two groups are isomorphic.
You could still introduce the class in a later stage of the series
There's an accidental JS version now...
No idea how that happened
Naming conventions described in PEP 8 are strongly preferred in Python. https://www.python.org/dev/peps/pep-0008/#naming-conventions
Thank you for the link, I haven't done much programmaing before so I'm new to style guides. I think I've made it better, following the style for functions and variables.
Python sample tests are still using
isGroup
instead ofis_group
Good catch! I forgot to change my original code rather than just the template, updated Thanks!
Test cases are incomplete I think. My code passed all tests only with checking for closed and associative. It did not check for identity element or inverse element. I would advise (if possible) to have four sets+funcs that each match three of conditions, but fail on the fourth, forcing all conditions to be checked. (okay, it's not possible for inverse element cond to exist without identity element cond for example I suspect, so my suggestion probably is impossible to implement exactly, but I feel the spirit of suggestion has merit)
I've come up with three more tests that I think catch, associtivity, lack of identity and lack of an inverse while retaining the other three conditions. Thanks for the advice.
Sample test cases in python don't match test cases. They ask for str(bool) instead of bool, and testGroup4 is not a group ("y" is not in {"a", "b"}, did you mean "b" )?
Thank you! I don't know how I missed that, I didn't realise that when you press validate soloutions it doesn't check the examples. I've fixed it.