Post History
As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, mo...
Question
code-golf
#1: Initial revision
Find good coalitions
As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, more seats than the opposition). Moreover you don't want more parties than necessary in a coalition, that is, if you still have a majority after removing one of the parties, it's not a good coalition. You are given a list of parties and their number of seats. Your task is to output a list of good coalitions, where each coalition is given by a list of its members. For this task, a coalition may also consist of a single party. Input and output may be in any suitable form (e.g. they need not be lists, but can be sets, dictionaries, XML, …). Note that the order of the parties in each coalition does not matter, nor does the order of coalitions. For example, the output `[["nano", "vi"], ["nano", Emacs"], ["vi", "Emacs"]]` is equivalent to `[["vi", Emacs"], ["Emacs", "nano"], ["nano", "vi"]]`. This is <a class="badge is-tag">code-golf</a>, the shortest code wins. Test cases: ```text {"nano": 25} → [["nano"]] {"vi": 20, "Emacs": 21} → [["Emacs"]] {"vi": 20, "Emacs": 20} → [["vi", "Emacs"]] {"nano": 20, "vi": 15, "Emacs": 12} → [["nano", "vi"], ["nano", Emacs"], ["vi", "Emacs"]] {"nano": 25, "vi": 14, "Emacs": 8, "gedit": 6} → [["nano", "vi"], ["nano", "Emacs"], ["nano", "gedit"], ["vi", "Emacs", "gedit"]] {"nano": 16, "vi": 14, "Emacs": 8, "gedit": 6} → [["nano", "vi"], ["nano", "Emacs"], ["vi", "Emacs", "gedit"]] {"nano": 10, "vi": 10, "Emacs": 5, "gedit": 5} → [["nano", "vi"], ["nano", "Emacs", "gedit"], ["vi", "Emacs", "gedit]] ```