You've been tasked with identifying if there's a color of candy in a bag that represents the majority share of bag. 🍬 The majority element is one which takes up over half of the space in a collection. Given a list of elements representing the colors, return the color found as the majority, otherwise indicate that no majority has been found.
For a simple list, [Red, Red, Blue, Red, Green], the returned value should be Red because Red occurs 3 times out of a list of 5. But for a list [Red, Red, Blue, Green], there is no majority despite Red being the most common element because 2/4 is not greater than half of the elements.
majorityFinder function in any way you choose, we've provided a few stubs which use the MyStore ability. (The MyStore ability is the same as Store from the standard library, but here we've given it a slightly different name for disambiguation.) You'll need to implement the runWith handler if you choose to use this ability. runWith returns both the result of running the function which uses the MyStore ability and the final state of the MyStore.Sign up to Exercism to learn and master Unison with 52 exercises, and real human mentoring, all for free.