Question: Q1. Write a python program to choose one of 4 colours (red, blue, green, orange) for 6 regions of Pakistan such that adjacent regions are

 Q1. Write a python program to choose one of 4 colours

Q1. Write a python program to choose one of 4 colours (red, blue, green, orange) for 6 regions of Pakistan such that adjacent regions are not assigned the same colour. The 6 regions are Baluchistan (B), Sindh (s), Punjab (P), Khaybar-Pakhtunkhwa (KP), Kashmir (K) and Gilgit-Baltistan (GB). As you know B is adjacent to S, P and KP, P is adjacent to S, B and KP, KP is adjacent to B, P, K and GB, and K is adjacent to P, KP and GB. No graphical output is required, output similar to following is enough: {'B': 'red', 'P': 'blue', 'S':'green', 'KP': 'green','K': 'red', 'GB': 'blue'} For variables and domains defined as variables = ('B', 'P','S', 'KP', 'GB','K') domains = dict((v, ['red','blue','green','orange']) for v in variables) You are required to use Backtracking search for this constraint satisfaction problem. Submit your python code only. (20 Marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!