Discussion:
In need of help with haskell backtracking.
(too old to reply)
p***@gmail.com
2009-04-01 06:32:39 UTC
Permalink
I need a little help with my homework, here it is:

On the planet Gliese 581 there are two nations, which fight all the
time...as soon as one of the sides is dominant in numbers, it starts
attacking the second one. On peace discussions they decided, that the
solution is splitting the population in such way, that no adjacent
cities will have the same nation in them.(In ine city there are only
inhabitants from one nation.)

In the function input there is the adjacency of cities assigned by a
list [[m11,m21],[m12,m22],...,[m1N,m2N]], where the pairs [m1i,m2i]
says, that the cities m1i and m2i are adjacent.

The function result gives TRUE, if it is possible to inhabit all
cities, else it gives FALSE.

example:
peaceAble [[1,2],[2,3],[3,5],[4,5],[10,2],[11,3],[5,6],[8,9],[7,8],
[4,7],[5,8],[8,12]] ==> True
peaceAble [[1,2],[2,3],[3,1]] ==> False
Paul Rubin
2009-04-01 06:38:20 UTC
Permalink
Post by p***@gmail.com
I need a little help with my homework
Your hint is to look up "graph coloring".

Loading...