I am using clingo to solve flood-it problems. I use the predicate frontier([CELL], [COLOR], [TIMESTEP])
to keep track of all cells that are neighbors of the flood. The set of frontiers could look something like this:
frontier(c(1,3),2,3) frontier(c(2,1),2,3) frontier(c(2,2),3,3) frontier(c(2,3),3,3) frontier(c(3,1),3,3) frontier(c(3,2),3,3) frontier(c(4,1),3,3)
We can split this set in two subsets. One where each color value is 2 or 3 respectively. What I need is basically two things:
- Determine which subset is bigger, i.e. if there are more cells with color value 2 or 3 (BTW the number of colors is not fixed, thus a solution has to be generic)
- Get the color value of a member of the biggest set
How can I compare the cardinalities of n (n>=2) sets in predicate logic?
Thank you in advance!