image/svg+xml
        
            var solver = new SolverJS.Solver();

            // Initialize a domain that will be used by all variables.
            let colorDomain = solver.newDomain('red', 'green', 'blue');

            // Initialize a new variable for each region in the map with the color domain.
            let WA =    solver.newVariable('wa', colorDomain);
            let NT =    solver.newVariable('nt', colorDomain);
            let SA =    solver.newVariable('sa', colorDomain);
            let Q =     solver.newVariable('q', colorDomain);
            let NSW =   solver.newVariable('nsw', colorDomain);
            let V =     solver.newVariable('v', colorDomain);
            let T =     solver.newVariable('t', colorDomain);
                    
            // Initialize constraints that require neighboring regions to have distinct colors.
            solver.newConstraint((a,b)=> a != b, SA, WA);
            solver.newConstraint((a,b)=> a != b, SA, NT);
            solver.newConstraint((a,b)=> a != b, SA, Q);
            solver.newConstraint((a,b)=> a != b, SA, NSW);
            solver.newConstraint((a,b)=> a != b, SA, V);
            solver.newConstraint((a,b)=> a != b, WA, NT);
            solver.newConstraint((a,b)=> a != b, NT, Q);
            solver.newConstraint((a,b)=> a != b, Q, NSW);
            solver.newConstraint((a,b)=> a != b, NSW, V);

            // Let the solver assign values to each of the variables. The solve method will return a boolean value 
            // indicating whether or not it was able to find a solution that satisfies all the constraints.
            let result = solver.solve();

            if(result){ 
                // If a solution was found, iterate over the variables and assign a CSS class to the corresponding map regions 
                // with the variable's value as a CSS class name.
                for(var i = 0; i < solver._variables.length; i++){
                    document.getElementById(solver._variables[i]._name).classList.add(solver._variables[i].value);
                }
            }else{
                alert('Failed to find a solution!');
            }