
balance _ = "" Haha!
The other trivial solution simply replaces each parenthesis by "()": balance = concatMap $ const "()" balance "))(" then returns "()()()". This achieves that the balanced string is a superstring of the original string. (Not a minimal one.) On 21.03.2017 18:23, Michael Orlitzky wrote:
On 03/21/2017 01:16 PM, David McBride wrote:
Whether your algorithm is correct depends on how you are supposed to rebalance them. My naive attempt gives very different results.
You guys are trying to hard. Here's an algorithm that meets the stated requirements:
balance _ = "" -- Andreas Abel <>< Du bist der geliebte Mensch.
Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www.cse.chalmers.se/~abela/