#include "map.h" #include bool ColorMap(int country, map& world) { if (country == world.numOfCountries) { // success; base case return true; } //std::cout << country << std::endl; bool doneColoring = false; bool aColorRemaining = true; color hue = red; while (doneColoring == false && aColorRemaining == true) { //std::cout << world; if (world.isValidColoring(country, hue) == true) { world.colorCountry(country, hue); doneColoring = ColorMap(country + 1, world); // recursion } if (hue == yellow) aColorRemaining = false; else ++hue; } //std::cout << world; if (doneColoring == false) world.colorCountry(country, color(none)); // backtracking return doneColoring; } int main() { map world; std::ifstream in("map.txt"); in >> world; //std::cout << world; ColorMap(0, world); std::cout << world; in.close(); }