arimbun

The Friends problem

Tags: ,

This is a good programming practice of creating a recursive descent parser besides the calculator itself. The Friends problem calculates the set union(s) or set difference(s) between a given number of sets.

Sample input

{ABC}
{ABC}+{DEFG}+{Z}+{}
{ABE}*{ABCD}
{ABCD}-{CZ}
{ABC}+{CDE}*{CEZ}
({ABC}+{CDE})*{CEZ}

Sample output

{ABC}
{ABCDEFGZ}
{AB}
{ABD}
{ABCE}
{CE}

Source code is available on my GitHub.

Tags: ,

Leave a Reply

© 2010 arimbun

Powered by Wordpress and Magatheme