(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 4.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 45439, 739]*) (*NotebookOutlinePosition[ 46141, 763]*) (* CellTagsIndexPosition[ 46097, 759]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Four-Color Theorem Game", "Title", TextAlignment->Center], Cell[TextData[{ "Game written by Rolf Mertig (originally in german in 1998), Mertig \ Consulting, ", ButtonBox["http://www.mertig.com", ButtonData:>{ URL[ "http://www.mertig.com"], None}, ButtonStyle->"Hyperlink"] }], "Text"], Cell["\<\ Software distributed as is. Feel free use, modify, add other geometries, but please indicate here that \ you did.\ \>", "SmallText"], Cell["Click below to start the game.", "Text"], Cell[BoxData[ ButtonBox[ StyleBox[\(Start\ game\), "Subtitle"], ButtonFunction:>CompoundExpression[ ToExpression[ ToExpression[ BoxData[ "\"startit[]:=(\\n(* code \ *)\\nOff[General::spell];\\nOff[General::spell1];\\n(* Languages \ *)\\n$GameLanguage = \\\"Deutsch\\\";\\n$GameLanguage = \ \\\"English\\\";\\nTranslate[lang_][x_]:= Which[lang === \\\"English\\\", \ x,\\n\\t\\t lang === \\\"Deutsch\\\", \ x/.English2German];\\nClear[tra];tra[z_]:=tra[z]=Translate[$GameLanguage][z];\ \\nEnglish2German = {\\n\\t\\t\\\"The game is over\\\"->\\\"Das Spiel ist aus\ \\\",\\n\\t\\t\\\"statistics\\\" -> \\\"Statistik\\\",\\n\\t\\t\\t\\\"time \ used\\\" ->\\\"Ben\\\\:00f6tigte \ Zeit\\\",\\n\\t\\t\\t\\t\\\"seconds\\\"->\\\"Sekunden\\\",\\n\\t\\t\\\"Done!\\\ \"->\\\"Fertig!\\\",\\n\\t\\t\\\"You have finished \ successfully!\\\"->\\n\\t\\t\\t\\\"Du hast's \ geschafft!\\\",\\n\\t\\t\\\"red\\\"->\\\"rot\\\",\\n\\t\\t\\\"green\\\"->\\\"\ gr\\\\:00fcn\\\",\\n\\t\\t\\\"blue\\\"->\\\"blau\\\",\\n\\t\\t\\\"yellow\\\"->\ \\\"gelb\\\",\\n\\t\\t\\\"white\\\"->\\\"weiss\\\",\\n\\t\\t\\\"colorings\\\"-\ >\\\"Einf\\\\:00e4rbungen\\\",\\n\\t\\t\\\"failures\\\"->\\\"Fehler\\\",\\n \ \\\"Africa\\\" -> \\\"Afrika\\\",\\n \\\"Algeria\\\" -> \\\"Algerien\\\",\\n \ \\\"Botswana\\\" -> \\\"Botsuana\\\",\\n \\\"Burkina\\\" -> \\\"Burkina \ Faso\\\",\\n \\\"Cameroon\\\" -> \\\"Kamerun\\\",\\n \\\"CAR\\\" -> \ \\\"Zentral-Afrik. Rep.\\\",\\n \\\"Chad\\\" -> \\\"Tschad\\\",\\n \ \\\"Congo\\\" -> \\\"Kongo\\\",\\n \\\"Cote d'Ivoire\\\" -> \ \\\"Elfenbeink\\\\:00fcste\\\",\\n \\\"Djibouti\\\" -> \\\"Dschibuti\\\",\\n \ \\\"Egypt\\\" -> \\\"\\\\:00c4gypten\\\",\\n \\\"Equatorial Guinea\\\" -> \ \\\"\\\\:00c4quatorialguinea\\\",\\n \\\"Ethiopia\\\" -> \ \\\"\\\\:00c4thiopien\\\",\\n \\\"Gabon\\\" -> \\\"Gabun\\\",\\n \ \\\"Kenya\\\" -> \\\"Kenia\\\",\\n \\\"Libya\\\" -> \\\"Libyen\\\",\\n \ \\\"Madagascar\\\" -> \\\"Madagaskar\\\",\\n \\\"Mauritania\\\" -> \ \\\"Mauretanien\\\",\\n \\\"Morocco\\\" -> \\\"Marokko\\\",\\n \\\"Mozambique\ \\\" -> \\\"Mosambik\\\",\\n \\\"Rwanda\\\" -> \\\"Ruanda\\\",\\n \\\"South \ Africa\\\" -> \\\"S\\\\:00fcdafrika\\\",\\n \\\"Swaziland\\\" -> \ \\\"Swasiland\\\",\\n \\\"Tanzania\\\" -> \\\"Tansania\\\",\\n \\\"The Gambia\ \\\" -> \\\"Gambia\\\",\\n \\\"Tunisia\\\" -> \\\"Tunesien\\\",\\n \ \\\"Western Sahara\\\" -> \\\"Sahara\\\",\\n \\\"Zambia\\\" -> \ \\\"Sambia\\\",\\n \\\"Zimbabwe\\\" -> \\\"Simbabwe\\\"\\n,\\n\\\"Countries \ of Africa\\\"->\\\"L\\\\:00e4nder in \ Afrika\\\",\\n\\t\\t\\\"Neighbors\\\"->\\\"Nachbarn\\\",\\n\\t\\t\\t\\\"\ Neighbor\\\"->\\\"Nachbar\\\",\\n\\t\\t\\\"The Neighbors of\\\" -> \\\"Die \ Nachbarn von\\\",\\n\\t\\t\\t\\\"The Neighbor of\\\" -> \\\"Der Nachbar von\\\ \",\\n\\t\\t\\\"are\\\" -> \\\"sind\\\",\\\"is\\\" -> \\\"ist\\\",\\n\\t\\t\\\ \"has\\\"->\\\"hat\\\",\\\"no\\\"->\\\"keine\\\",\\n\\t\\t\\\"BAD!\\\"->\\\"\ Falsch!\\\",\\n\\t\\t\\\"A neighboring country has already this color. Try \ another color!\\\"->\\n\\t\\t\\\"Ein Nachbarland hat schon diese Farbe.\\n\\t\ \\t\\t\\tVersuch' eine andere Farbe!\\\",\\n\\t\\t\\\"Click on the black \ country buttons for a list of neighbors\\\"->\\n \\\"Klick' auf die \ schwarzen L\\\\:00e4nderfelder f\\\\:00fcr \\\\\\neine Liste der \ Nachbarn\\\"}/.( z_Symbol ->w_Symbol):> \ ToString[z]->ToString[w];\\n(*\\nprogram \\n*)\\n(*\\n get the option for \ ScreenRectangle\\n*)\\ndummynb = \ NotebookCreate[Visible->False];\\nscreenrectopt= \ Options[dummynb,ScreenRectangle][[1]];\\nNotebookDelete[dummynb];\\n(*\\nLoad \ Miscellaneous`WorldPlot\\n*)\\nNeeds[\\\"Miscellaneous`WorldPlot`\\\"];\\\ nMiscellaneous`WorldNames`Europe = \ \\\\\\nSelect[Miscellaneous`WorldNames`Europe,(#=!=\\\"San \ Marino\\\")&];\\nMiscellaneous`WorldNames`Africa = \ \\\\\\nSelect[Miscellaneous`WorldNames`Africa,(#=!=\\\"Madagascar\\\")&];\\\ nMiscellaneous`WorldNames`Africa = \ Sort[Miscellaneous`WorldNames`Africa];\\nMiscellaneous`WorldNames`Africa = \\\ \\\\nAppend[Select[Miscellaneous`WorldNames`Africa, \ (#=!=\\\"Lesotho\\\")&],\\\"Lesotho\\\"];\\n(*\\nNeighbors\\n*)\\nwdat[z_\ String]:=Flatten[Miscellaneous`WorldData`WorldData[z],1];\\nsame[{x_,y_},{a_,\ b_}]:=\\n\\t\\tIf[ (Abs[x-a]<2)&&(Abs[y-b]<2), \ True,False];\\nSameBorderQ[c1_String, c2_String] := \\nSameBorderQ[c1,c2]=\\n \ Length[Intersection[wdat[c1], \\n wdat[c2],SameTest->same]] > 0; \ \\nClear[Neighbors]; \ \\nNeighbors[s_String,con_:Miscellaneous`WorldNames`World] := \\n \ Neighbors[s] = \\n If[ !MemberQ[con, s], {}, \\n \ Sort@Select[Select[con, \\n SameBorderQ[#1, s] & ], \\n #1 =!= s \ & ]]; \\n(*\\ngenerate the \ palette\\n*)\\n{Red,Green,Blue,Yellow,White}=\\nApply[RGBColor,#]&/@{ \ {1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,1,1}};\\ncountrycolor[s_String]:=RGBColor[\ 1,1,1];\\n$ColoringCount=0;\\n$WrongColorCount=0;\\nSameColorWithNeighborsQ[s_\ String] := \\n If[countrycolor[s]===White, False,\\n \ MemberQ[countrycolor/@Neighbors[s], \ countrycolor[s]]];\\nClear[cp,fu,tobutton,countryfix];\\ncp[s_List]:=\\ncp[#,\ Table[countrycolor[#[[i]]],\\n{i,Length[#]}]]&[Sort[s,OrderedQ[{tra[#1],tra[#\ 2]}]&]];\\ncp[s_List,c_List]:=cp[Append[s,\\\"\\\"],\\nAppend[c,White]]/;OddQ[\ Length[s]];\\ngrop = \ Sequence[RowSpacings->0,ColumnSpacings->0];\\nfuu[{s1_,s2_},{c1_,c2_},con_]:=\ \\n{GridBox[{{tobutton[s1,c1,con],tobutton[s2,c2,con]}},\\nColumnAlignments->{\ Left},grop]};\\n(*\\nneighbornb (create the notebook telling the neighboring \ countries)\\n*)\\nneighbornb[s_String,con_]:=Block[{(*com,ne,cine*)},\\nIf[\ Head[$OldNB] === NotebookObject, \\n NotebookClose[$OldNB]\\n ];\\n cine \ = circleneighbors[s];\\n If[(com=Complement[cine,ToExpression@con])=!={},\\n \ cine = Select[cine,!MemberQ[com,#]&]\\n ];\\nne = $OldNB = \ \\nNotebookPut[Notebook[{Cell[\\\" \ \\\",\\\"Text\\\"]},\\nscreenrectopt,\\nWindowToolbars->{},\\nPageWidth->651,\ \\nWindowSize->{600, 109},\\nWindowMargins->{{1,Automatic}, \ {2,Automatic}},\\nWindowElements->{},\\nWindowFrameElements->\\\"CloseBox\\\",\ \\nWindowClickSelect->False,\\nScrollingOptions->{\\\"PagewiseScrolling\\\"->\ True},\\nShowCellBracket->False,\\nCellMargins->{{0, 0}, {Inherited, \ 0}},\\nActive->True,\\nCellOpen->True,\\nShowCellLabel->False,\\nShowCellTags-\ >False,\\nImageMargins->{{0, Inherited}, {Inherited, \ 0}},\\nWindowTitle->\\n(If[Length[cine]===0,tra[s]<>\\\" \ \\\"<>tra[\\\"has\\\"]<>\\n\\\" \\\"<>tra[\\\"no\\\"]<>\\\" \ \\\"<>\\ntra[\\\"Neighbors\\\"]<>\\\" \\\"<>\\\"in\\\" <> \\\" \ \\\"<>tra[con],\\nIf[Length[cine] === 1, \\n tra[\\\"The Neighbor \ of\\\"],\\n tra[\\\"The Neighbors of\\\"]]<>\\\" \\\"<>tra[s]<>\\\" in \ \\\"<> \\ntra[con] <> \\\" \\\"<> If[Length[cine]===1,\\ntra[\\\"is\\\"],tra[\ \\\"are\\\"]]<>\\\":\\\"]),\\nBackground->RGBColor[.9,0.7,0],\\nMagnification-\ >1.5\\n]];\\nSetOptions[ne, WindowMargins->{{1,Automatic}, \ {2,Automatic}}];\\nSelectionMove[ne, After, Notebook];\\nnei = \ StringJoin[#,\\n\\\", \\\"]&/@Map[tra,cine];\\nIf[Length[nei]>0,\\nnei = \ Append[Drop[nei,-1],\\nStringDrop[nei//Last, \ -2]<>\\\".\\\"]];\\nNotebookWrite[ne,\\nCell[TextData[RowBox[nei]],\\\"Text\\\ \"]];];\\n(*\\ntobotton\\n*)\\nClear[countryfix];\\n(*defcountryfix*)\\\ ncountryfix[s_String,c_RGBColor]:= GridBox[{{\\nRowBox[{\\\" \\\", \ InterpretationBox@@{\\nStyleBox[tra@s,FontColor->c,FontWeight->\\\"Bold\\\"],\ s}}]\\n}}, ColumnWidths->cowi, \ ColumnAlignments->{Left}];\\nClear[tobutton];\\ntobutton[\\\"\\\",__]=\\\"\\\"\ ;\\ntobutton[s_,c_,con_:Miscellaneous`WorldNames`World]:=GridBox[{{\\nGridBox[\ {{ButtonBox[countryfix[s,c], \ \\nButtonEvaluator->Automatic,\\nButtonMargins->3,Background->GrayLevel[0],\\\ nButtonFunction:>neighbornb[s,con]]}},grop],\\n GridBox[{{ButtonBox[\\n\\\ \" \\\",Background->Red,ButtonMargins->3,\\nButtonEvaluator->Automatic,\ ButtonFunction:>\\nbufu[s,Red][ButtonNotebook[]]\\n],\\nButtonBox[\\n\\\" \ \\\",Background->Green,ButtonMargins->3,\\nButtonEvaluator->Automatic,\ ButtonFunction:>\\nbufu[s,Green][ButtonNotebook[]]\\n],\\nButtonBox[\\n\\\" \ \\\",Background->Blue,ButtonMargins->3,\\nButtonEvaluator->Automatic,\ ButtonFunction:>\\nbufu[s,Blue][ButtonNotebook[]]\\n],\\nButtonBox[\\n\\\" \\\ \",\\nBackground->Yellow,ButtonMargins->3,\\nButtonEvaluator->Automatic,\ ButtonFunction:>\\nbufu[s,Yellow][ButtonNotebook[]]\\n],\\nButtonBox[\\n\\\" \ \\\",\\nBackground->White,ButtonMargins->3,\\nButtonEvaluator->Automatic,\ ButtonFunction:>\\nbufu[s,White][ButtonNotebook[]]\\n]\\n}},grop]}}\\n,grop,\ ColumnAlignments->{Left,Right}];\\n(*\\nMeasure how many times country colors \ have been \ changed.\\n*)\\nClear[bufu];\\nbufu[s_String,nc_RGBColor][nb_NotebookObject]:=\ \\n If[ countrycolor[s] =!= nc,\\nBlock[{re,oldc=countrycolor[s]}, \ \\nIf[Head[nono]===NotebookObject, \ NotebookClose[nono];\\nUnset[nono]];\\ncountrycolor[s] = \ nc;\\nIf[SameColorWithNeighborsQ[s],\\ncountrycolor[s]=oldc;\\n$\ WrongColorCount++;\\nnono=\\nNotebookPut[Notebook[\\n{Cell[tra@\\\"BAD!\\\",\\\ \"Title\\\"],\\nCell[tra@\\\"A neighboring country has already this color. \ Try another \ \\\\\\ncolor!\\\",\\\"Subtitle\\\"]\\n},\\nscreenrectopt,\\nWindowToolbars->{}\ ,\\nPageWidth->651,\\nWindowSize->{552, \ 314},\\nWindowMargins->{{0,Automatic}, \ {0,Automatic}},\\nWindowElements->{},\\nWindowFrameElements->\\\"CloseBox\\\",\ \\nWindowClickSelect->False,\\nScrollingOptions->{\\\"PagewiseScrolling\\\"->\ True},\\nShowCellBracket->False,\\nCellMargins->{{0, 0}, {Inherited, \ 0}},\\nActive->True,\\nCellOpen->True,\\nShowCellLabel->False,\\nShowCellTags-\ >False,\\nImageMargins->{{0, Inherited}, {Inherited, \ 0}},\\nWindowTitle->\\\"Wrong \ input\\\",\\nBackground->(*RGBColor[.9,0.2,0]*)nc,\\nMagnification->1.5\\n]];\ \\nSetOptions[nono,WindowMargins->{{0,Automatic}, \ {0,Automatic}}];\\n,\\nIf[Head[nono]===NotebookObject,NotebookClose[nono]];\\\ n$ColoringCount++;\\ncountrycolor[s] = nc;\\n\\tSelectionMove[nb, All, \ Notebook];\\n re = NotebookRead[nb]/.\\n InterpretationBox[\\n \ StyleBox[es_,fs___,FontColor->_,fr___],se_] :> \\n \ ifun[es,fs,FontColor->countrycolor[se],fr,se]/.\\n ifun[a_,b__, c_] :> \\n( \ InterpretationBox[StyleBox[a,b],c] );\\n NotebookWrite[nb,re];\\nplotit]\\n \ ]];\\ncp[s_List \ /;EvenQ[Length[s]],c_List]:=\\nGridBox[Thread[fu[Partition[s,2],Partition[c,2]\ ]],\\ngrop,ColumnAlignments->{Left}];\\nplotit:=(SelectionMove[na,Before,\ Notebook];\\n SelectionMove[na,Next,Cell];\\n \ SelectionEvaluate[na];\\n SelectionMove[na,Before,Notebook];\\n \ SetOptions[na, \ WindowTitle->statistics[]]);\\nstatistics[x___]:=Block[{c,r,g,b,y,w},\\nc=\ countrycolor/@$Continent;\\nr= Cases[c,Red]//Length;\\ng= \ Cases[c,Green]//Length;\\nb= Cases[c,Blue]//Length;\\ny= \ Cases[c,Yellow]//Length;\\nw= Cases[c,White]//Length;\\n\\t\\tIf[ \ Length[$Continent]===(w+1), $StartTime = AbsoluteTime[]];\\nIf[w === 0 && \ {x}=!={False},\\n\\t\\t\\t$GameTime= \ Round[AbsoluteTime[]-$StartTime];\\nreno=NotebookPut[\\nNotebook[\\n{Cell[tra@\ \\\"Done!\\\",\\\"Title\\\"],\\nCell[tra@\\\"You have finished \ successfully!\\\", \ \\\"Subtitle\\\"],\\n\\t\\t\\t\\t\\tCell[tra[\\\"statistics\\\"],\\\"Section\\\ \"],\\n Cell[tra[statistics[False]],\\\"Text\\\"],\\n\\t\\t\\t\\t\\tCell[\\n \ tra[\\\"time used\\\"] <> \\\" : \\\"<>ToString[$GameTime]<>\\\ \" \\\" <> \\n \ tra[\\\"seconds\\\"],\\\"Text\\\"]\\n},\\nscreenrectopt,\\nWindowToolbars->{},\ \\nPageWidth->651,\\nWindowSize->{422,575},\\nWindowMargins->{{Automatic,28},{\ Automatic,20}},\\nWindowElements->{},\\nWindowFrameElements->\\\"CloseBox\\\",\ \\nWindowClickSelect->False,\\nScrollingOptions->{\\\"PagewiseScrolling\\\"->\ True},\\nShowCellBracket->False,\\nCellMargins->{{0, 0}, {Inherited, \ 0}},\\nActive->True,\\nCellOpen->True,\\nShowCellLabel->False,\\nShowCellTags-\ >False,\\nImageMargins->{{0, Inherited}, {Inherited, 0}},\\nWindowTitle->tra[\ \\\"The game is \ over\\\"],\\nBackground->RGBColor[.9,0.2,0],\\nMagnification->1.5\\n] ] \ ];\\nStringJoin@@Map[ToString,{tra[\\\"red\\\"],\\\": \\\",r,\\\" \\\",tra[\ \\\"green\\\"],\\\": \\\",g,\\n\\\" \\\",tra[\\\"blue\\\"],\\\": \ \\\",b,\\\" \\\",tra[\\\"yellow\\\"],\\\": \\\",y,\\\" \ \\\",tra[\\\"white\\\"],\\\": \\\",\\nw,\\\" \\\", \ tra[\\\"colorings\\\"],\\\": \\\",$ColoringCount,\\\" \ \\\",tra[\\\"failures\\\"],\\n \\\": \\\", \ $WrongColorCount}]\\n];\\n\\n(*\\ndatabase of neighboring countries\\n*)\\n(*\ \\ncode\\n*)\\nhandswitch[a_]:=a;\\nhandswitch[{\\\"Bolivia\\\",\\\"Paraguay\\\ \"}] = {\\\"Paraguay\\\",\\\"Bolivia\\\"};\\nhandswitch[{\\\"Bhutan\\\", \ \\\"Nepal\\\", \\\"Pakistan\\\"}] = \ {\\\"Pakistan\\\"};\\nhandswitch[{\\\"Mongolia\\\", \\\"North Korea\\\"}] = {\ \\\"North \ Korea\\\"};\\nFirst2[{}]=False;\\nFirst2[a_]:=First[a];\\nClear[\ circleneighbors];\\ncircleneighbors[\\\"Russia\\\"]={\\\"Norway\\\", \ \\\"Finland\\\", \\\"North Korea\\\", \\\"China\\\", \\n \\\"Mongolia\\\", \ \\n \\\"Kazakhstan\\\", \\\"Georgia\\\", \\\"Azerbaijan\\\", \ \\\"Ukraine\\\", \\n \ \\\"Belarus\\\",\\\"Latvia\\\",\\\"Estonia\\\",\\\"Lithuania\\\", \ \\\"Poland\\\"};\\ncircleneighbors[\\\"France\\\"]={\\\"Spain\\\", \ \\\"Andorra\\\", \\\"Monaco\\\", \\\"Italy\\\", \\n \ \\\"Switzerland\\\",\\\"Germany\\\",\\\"Luxembourg\\\", \\n \ \\\"Belgium\\\"};\\ncircleneighbors[\\\"Iran\\\"]=\\n{\\\"Turkmenistan\\\", \ \\\"Afghanistan\\\", \\\"Pakistan\\\", \\\"Iraq\\\", \\\"Turkey\\\",\\n \ \\\"Armenia\\\", \ \\\"Azerbaijan\\\"};\\ncircleneighbors[\\\"Lesotho\\\"]={\\\"South \ Africa\\\"};\\ncircleneighbors[s_String]:=circleneighbors[s] \ =\\n\\t\\tBlock[{(*nei,new*)},\\n\\t\\tnei=Neighbors[s];\\n\\t\\tinei=nei;\\n\ \\t\\tIf[Length[nei]>2,\\n\\t\\tnei=Sort[nei, \ (Length[Intersection[Neighbors[#1],nei]]<\\n\\t\\t \ Length[Intersection[Neighbors[#2],nei]])&];\\n\\t\\t\\tIf[MemberQ[{\\\"Panama\ \\\",\\\"Monaco\\\",\\\"Denmark\\\",\\\"Spain\\\"},First[nei]], \\n \ nei = RotateLeft[nei]];\\n\\t\\t\\tonei = nei;\\n\\t\\tnew={First[nei]};nei = \ Rest[nei];\\n\\t\\t\\tonew = \ new;\\n\\t\\t\\tDo[nel=nhn[iji]=\\n\\t\\t\\t\\t\\t\\t\\tFirst2[handswitch[HH[\ iji]=Intersection[NN=Neighbors[Last[new]],nei]]];\\n\\t\\t\\t\\tIf[nel =!= \ False, new = Append[new, nel];\\n\\t\\t\\t\\t nei = \ Select[nei,(#=!=nel)&];\\n\\t\\t\\t\\t\\t \ ];\\n\\t\\t\\t\\tneiw[iji]=nei;\\n\\t\\t\\t\\tneww[iji]=new,\\n\\t\\t\\t\\t{\ iji,Length[nei]-1}];\\n\\t\\t\\tnein=nei;\\n\\t\\t\\tjaja=new;\\n\\tDo[ nnn = \ nei[[j]];\\n\\t\\t\\tIf[SameBorderQ[Last[new],nnn],\\n\\t\\t \ \\tAppendTo[new,Last[nei]],\\n\\t\\t\\t\\t\\tCatch[\\n\\t\\t\\t\\t (* \ Paraguay, e.g., can escape the algorithm above*)\\n\\t\\t\\t\\t \ Do[If[SameBorderQ[nnn,new[[jj]]] &&\\n\\t\\t\\t\\t\\t\\t \ SameBorderQ[nnn,new[[jj+1]]],\\n\\t\\t\\t\\t\\t\\t Throw[new = \ Insert[new,nnn,jj+1]]],\\n\\t\\t\\t\\t\\t\\t \ {jj,Length[new]-1}];\\n\\t\\t\\t\\t\\t\\t Do[If[SameBorderQ[nnn,new[[jj]]] \ ,\\n\\t\\t\\t\\t\\t\\t Throw[new = \ Insert[new,nnn,jj+1]]],\\n\\t\\t\\t\\t\\t\\t {jj,Length[new]}];\\n\\t\ \\t\\t\\t\\t\\tnew=Append[new,nnn]]\\n\\t\\t\\t\\t \ ],{j,Length[nei]}];\\n\\t\\t\\tnew\\n\\t\\t\\t\\t,nei\\n\\t\\t]\\n\\t];\\n(*\\\ n database\\n*)\\nDownValues[circleneighbors] \ =\\n{HoldPattern[circleneighbors[\\\"Afghanistan\\\"]] :> \\n \ {\\\"Uzbekistan\\\", \\\"Tajikistan\\\", \\\"China\\\", \\\"Pakistan\\\", \ \\\"Iran\\\", \\\"Turkmenistan\\\"}, \\\\\\n\\n HoldPattern[circleneighbors[\ \\\"Albania\\\"]] :> \\n {\\\"Serbia and Montenegro\\\", \\\"Macedonia\\\", \ \\\"Greece\\\"}, \\n HoldPattern[circleneighbors[\\\"Algeria\\\"]] :> \\n \ {\\\"Tunisia\\\", \\\"Libya\\\", \\\"Niger\\\", \\\"Mali\\\", \ \\\"Mauritania\\\", \\\"Western Sahara\\\", \\n \\\"Morocco\\\"}, \ HoldPattern[circleneighbors[\\\"Andorra\\\"]] :> \\n {\\\"France\\\", \ \\\"Spain\\\"}, HoldPattern[circleneighbors[\\\"Angola\\\"]] :> \\n \ {\\\"Zaire\\\", \\\"Zambia\\\", \\\"Namibia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Antarctica\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Argentina\\\"]] :> \\n {\\\"Uruguay\\\", \\\ \"Brazil\\\", \\\"Paraguay\\\", \\\"Bolivia\\\", \\\"Chile\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Armenia\\\"]] :> \\n {\\\"Iran\\\", \ \\\"Azerbaijan\\\", \\\"Georgia\\\", \\\"Turkey\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Australia\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Austria\\\"]] :> \\n \ {\\\"Liechtenstein\\\", \\\"Switzerland\\\", \\\"Germany\\\", \\\"Czech \ Republic\\\", \\\"Slovakia\\\", \\n \\\"Hungary\\\", \\\"Slovenia\\\", \ \\\"Italy\\\"}, \\n HoldPattern[circleneighbors[\\\"Azerbaijan\\\"]] :> \\n \ {\\\"Russia\\\", \\\"Georgia\\\", \\\"Armenia\\\", \\\"Iran\\\", \ \\\"Turkey\\\"}, \\n HoldPattern[circleneighbors[\\\"Bahrain\\\"]] :> {}, \ \\n HoldPattern[circleneighbors[\\\"Bangladesh\\\"]] :> {\\\"Burma\\\", \ \\\"India\\\"}, \\n HoldPattern[circleneighbors[\\\"Belarus\\\"]] :> \\n {\ \\\"Ukraine\\\", \\\"Poland\\\", \\\"Lithuania\\\", \\\"Latvia\\\", \ \\\"Russia\\\"}, \\n HoldPattern[circleneighbors[\\\"Belgium\\\"]] :> \\n \ {\\\"Netherlands\\\", \\\"Germany\\\", \\\"France\\\", \\\"Luxembourg\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Belize\\\"]] :> {\\\"Guatemala\\\", \ \\\"Mexico\\\"}, \\n HoldPattern[circleneighbors[\\\"Benin\\\"]] :> \\n \ {\\\"Togo\\\", \\\"Burkina\\\", \\\"Niger\\\", \\\"Nigeria\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Bermuda\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Bhutan\\\"]] :> {\\\"China\\\", \ \\\"India\\\"}, \\n HoldPattern[circleneighbors[\\\"Bolivia\\\"]] :> \\n {\ \\\"Peru\\\", \\\"Brazil\\\", \\\"Paraguay\\\", \\\"Argentina\\\", \ \\\"Chile\\\"}, \\n HoldPattern[circleneighbors[\\\"Bosnia and Herzegovina\\\ \"]] :> \\n {\\\"Croatia\\\", \\\"Serbia and Montenegro\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Botswana\\\"]] :> \\n {\\\"Zambia\\\", \ \\\"Namibia\\\", \\\"South Africa\\\", \\\"Zimbabwe\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Brazil\\\"]] :> \\n {\\\"Uruguay\\\", \ \\\"Argentina\\\", \\\"Paraguay\\\", \\\"Bolivia\\\", \\\"Peru\\\", \ \\\"Colombia\\\", \\n \\\"Venezuela\\\", \\\"Guyana\\\", \\\"Suriname\\\", \ \\\"French Guiana\\\"}, \\n HoldPattern[circleneighbors[\\\"Brunei\\\"]] :> \ {\\\"Malaysia\\\"}, \\n HoldPattern[circleneighbors[\\\"Bulgaria\\\"]] :> \ \\n {\\\"Turkey\\\", \\\"Greece\\\", \\\"Macedonia\\\", \\\"Serbia and \ Montenegro\\\", \\\"Romania\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Burkina\\\"]] :> \\n {\\\"Togo\\\", \ \\\"Benin\\\", \\\"Niger\\\", \\\"Mali\\\", \\\"Cote d'Ivoire\\\", \ \\\"Ghana\\\"}, \\n HoldPattern[circleneighbors[\\\"Burma\\\"]] :> \\n {\\\ \"Thailand\\\", \\\"Laos\\\", \\\"China\\\", \\\"India\\\", \ \\\"Bangladesh\\\"}, \\n HoldPattern[circleneighbors[\\\"Burundi\\\"]] :> \ {\\\"Zaire\\\", \\\"Rwanda\\\", \\\"Tanzania\\\"}, \\\\\\n\\n \ HoldPattern[circleneighbors[\\\"Cabinda\\\"]] :> {\\\"Congo\\\", \ \\\"Zaire\\\"}, \\n HoldPattern[circleneighbors[\\\"Cambodia\\\"]] :> \\n \ {\\\"Vietnam\\\", \\\"Laos\\\", \\\"Thailand\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Cameroon\\\"]] :> \\n {\\\"Nigeria\\\", \ \\\"Chad\\\", \\\"CAR\\\", \\\"Congo\\\", \\\"Gabon\\\", \\\"Equatorial \ Guinea\\\"}, \\n HoldPattern[circleneighbors[\\\"Canada\\\"]] :> \ {\\\"USA\\\"}, \\n HoldPattern[circleneighbors[\\\"CAR\\\"]] :> \\n \ {\\\"Zaire\\\", \\\"Congo\\\", \\\"Cameroon\\\", \\\"Chad\\\", \ \\\"Sudan\\\"}, \\n HoldPattern[circleneighbors[\\\"Chad\\\"]] :> \\n \ {\\\"Sudan\\\", \\\"CAR\\\", \\\"Cameroon\\\", \\\"Nigeria\\\", \ \\\"Niger\\\", \\\"Libya\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Chile\\\"]] :> {\\\"Peru\\\", \ \\\"Bolivia\\\", \\\"Argentina\\\"}, \\n \ HoldPattern[circleneighbors[\\\"China\\\"]] :> \\n {\\\"Vietnam\\\", \ \\\"Laos\\\", \\\"Burma\\\", \\\"India\\\", \\\"Bhutan\\\", \\\"Nepal\\\", \\\ \"Pakistan\\\", \\n \\\"Afghanistan\\\", \\\"Tajikistan\\\", \ \\\"Kyrgyzstan\\\", \\\"Kazakhstan\\\", \\\"Russia\\\", \\n \\\"Mongolia\\\ \", \\\"North Korea\\\"}, \\n HoldPattern[circleneighbors[\\\"Colombia\\\"]] \ :> \\n {\\\"Venezuela\\\", \\\"Brazil\\\", \\\"Peru\\\", \\\"Ecuador\\\", \ \\\"Panama\\\"}, \\n HoldPattern[circleneighbors[\\\"Congo\\\"]] :> \\n \ {\\\"Gabon\\\", \\\"Cameroon\\\", \\\"CAR\\\", \\\"Zaire\\\", \ \\\"Cabinda\\\"}, \\n HoldPattern[circleneighbors[\\\"Costa Rica\\\"]] :> \ {\\\"Nicaragua\\\", \\\"Panama\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Cote d'Ivoire\\\"]] :> \\n \ {\\\"Liberia\\\", \\\"Guinea\\\", \\\"Mali\\\", \\\"Burkina\\\", \ \\\"Ghana\\\"}, \\n HoldPattern[circleneighbors[\\\"Croatia\\\"]] :> \\n {\ \\\"Slovenia\\\", \\\"Hungary\\\", \\\"Serbia and Montenegro\\\", \\\"Bosnia \ and Herzegovina\\\"}\\\\\\n\\\\\\n, \ HoldPattern[circleneighbors[\\\"Cuba\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Cyprus\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Czech Republic\\\"]] :> \\n {\\\"Slovakia\\\ \", \\\"Austria\\\", \\\"Germany\\\", \\\"Poland\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Denmark\\\"]] :> {\\\"Germany\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Djibouti\\\"]] :> \\n {\\\"Somalia\\\", \ \\\"Ethiopia\\\", \\\"Eritrea\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Dominican Republic\\\"]] :> {\\\"Haiti\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Ecuador\\\"]] :> {\\\"Colombia\\\", \ \\\"Peru\\\"}, \\n HoldPattern[circleneighbors[\\\"Egypt\\\"]] :> \\n \ {\\\"Sudan\\\", \\\"Libya\\\", \\\"Jordan\\\", \\\"Israel\\\"}, \\n \ HoldPattern[circleneighbors[\\\"El Salvador\\\"]] :> {\\\"Guatemala\\\", \ \\\"Honduras\\\"}, \\n HoldPattern[circleneighbors[\\\"Equatorial \ Guinea\\\"]] :> {\\\"Cameroon\\\", \\\"Gabon\\\"}, \\\\\\n\\n \ HoldPattern[circleneighbors[\\\"Eritrea\\\"]] :> \\n {\\\"Sudan\\\", \ \\\"Ethiopia\\\", \\\"Djibouti\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Estonia\\\"]] :> {\\\"Latvia\\\", \ \\\"Russia\\\"}, \\n HoldPattern[circleneighbors[\\\"Ethiopia\\\"]] :> \\n \ {\\\"Sudan\\\", \\\"Eritrea\\\", \\\"Djibouti\\\", \\\"Somalia\\\", \\\"Kenya\ \\\"}, \\n HoldPattern[circleneighbors[\\\"Falkland Islands\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Fiji\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Finland\\\"]] :> {\\\"Sweden\\\", \ \\\"Norway\\\", \\\"Russia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"France\\\"]] :> \\n {\\\"Spain\\\", \ \\\"Andorra\\\", \\\"Monaco\\\", \\\"Italy\\\", \\\"Switzerland\\\", \ \\\"Germany\\\", \\n \\\"Luxembourg\\\", \\\"Belgium\\\"}, \ HoldPattern[circleneighbors[\\\"French \\\\\\nGuiana\\\"]] \\\\\\n:> \ {\\\"Brazil\\\", \\\"Suriname\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Gabon\\\"]] :> \\n {\\\"Equatorial Guinea\\\ \", \\\"Cameroon\\\", \\\"Congo\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Georgia\\\"]] :> \\n {\\\"Russia\\\", \ \\\"Azerbaijan\\\", \\\"Armenia\\\", \\\"Turkey\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Germany\\\"]] :> \\n {\\\"Poland\\\", \ \\\"Czech Republic\\\", \\\"Austria\\\", \\\"Switzerland\\\", \\\"France\\\", \ \\n \\\"Belgium\\\", \\\"Netherlands\\\", \\\"Luxembourg\\\", \ \\\"Denmark\\\"}, \\n HoldPattern[circleneighbors[\\\"Ghana\\\"]] :> \\n {\ \\\"Togo\\\", \\\"Burkina\\\", \\\"Cote d'Ivoire\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Gibraltar\\\"]] :> {\\\"Spain\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Greece\\\"]] :> \\n {\\\"Turkey\\\", \ \\\"Bulgaria\\\", \\\"Macedonia\\\", \\\"Albania\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Greenland\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Guatemala\\\"]] :> \\n {\\\"Mexico\\\", \ \\\"Belize\\\", \\\"Honduras\\\", \\\"El Salvador\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Guinea\\\"]] :> \\n {\\\"Sierra Leone\\\", \ \\\"Liberia\\\", \\\"Cote d'Ivoire\\\", \\\"Mali\\\", \\\"Senegal\\\", \\n \ \\\"Guinea-Bissau\\\"}, HoldPattern[circleneighbors[\\\"Guinea-Bissau\\\"]] \ :> \\n {\\\"Guinea\\\", \\\"Senegal\\\"}, \ HoldPattern[circleneighbors[\\\"Guyana\\\"]] :> \\n {\\\"Venezuela\\\", \ \\\"Brazil\\\", \\\"Suriname\\\"}, \\n HoldPattern[circleneighbors[\\\"Haiti\ \\\"]] :> {\\\"Dominican Republic\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Honduras\\\"]] :> \\n {\\\"Nicaragua\\\", \ \\\"Guatemala\\\", \\\"El Salvador\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Hungary\\\"]] :> \\n {\\\"Ukraine\\\", \ \\\"Romania\\\", \\\"Serbia and Montenegro\\\", \\\"Croatia\\\", \\\"Slovenia\ \\\", \\n \\\"Austria\\\", \\\"Slovakia\\\"}, HoldPattern[circleneighbors[\ \\\"Iceland\\\"]] :> {}, \\n HoldPattern[circleneighbors[\\\"India\\\"]] :> \ \\n {\\\"Pakistan\\\", \\\"China\\\", \\\"Nepal\\\", \\\"Bhutan\\\", \ \\\"Bangladesh\\\", \\\"Burma\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Indonesia\\\"]] :> \\n {\\\"Malaysia\\\", \ \\\"Papua New Guinea\\\"}, \\n HoldPattern[circleneighbors[\\\"Iran\\\"]] :> \ \\n {\\\"Turkmenistan\\\", \\\"Afghanistan\\\", \\\"Pakistan\\\", \ \\\"Iraq\\\", \\\"Turkey\\\", \\\"Armenia\\\", \\n \\\"Azerbaijan\\\"}, \ HoldPattern[circleneighbors[\\\"Iraq\\\"]] :> \\n {\\\"Kuwait\\\", \ \\\"Saudi Arabia\\\", \\\"Jordan\\\", \\\"Syria\\\", \\\"Turkey\\\", \\\"Iran\ \\\"}, \\n HoldPattern[circleneighbors[\\\"Ireland\\\"]] :> {\\\"United \ Kingdom\\\"}, \\n HoldPattern[circleneighbors[\\\"Israel\\\"]] :> \\n \ {\\\"Lebanon\\\", \\\"Syria\\\", \\\"Jordan\\\", \\\"Egypt\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Italy\\\"]] :> \\n {\\\"Slovenia\\\", \ \\\"Austria\\\", \\\"Switzerland\\\", \\\"France\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Jamaica\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Japan\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Jordan\\\"]] :> \\n {\\\"Saudi Arabia\\\", \ \\\"Iraq\\\", \\\"Syria\\\", \\\"Israel\\\", \\\"Egypt\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Kazakhstan\\\"]] :> \\n {\\\"Turkmenistan\\\ \", \\\"Uzbekistan\\\", \\\"Kyrgyzstan\\\", \\\"China\\\", \\\"Russia\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Kenya\\\"]] :> \\n {\\\"Tanzania\\\", \ \\\"Uganda\\\", \\\"Sudan\\\", \\\"Ethiopia\\\", \\\"Somalia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Kuwait\\\"]] :> {\\\"Iraq\\\", \\\"Saudi \ Arabia\\\"}, \\n HoldPattern[circleneighbors[\\\"Kyrgyzstan\\\"]] :> \\n {\ \\\"Uzbekistan\\\", \\\"Kazakhstan\\\", \\\"China\\\", \\\"Tajikistan\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Laos\\\"]] :> \\n {\\\"Vietnam\\\", \\\ \"Cambodia\\\", \\\"Thailand\\\", \\\"Burma\\\", \\\"China\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Latvia\\\"]] :> \\n {\\\"Estonia\\\", \ \\\"Russia\\\", \\\"Belarus\\\", \\\"Lithuania\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Lebanon\\\"]] :> {\\\"Israel\\\", \\\"Syria\\\ \"}, \\n HoldPattern[circleneighbors[\\\"Lesotho\\\"]] :> {\\\"South \ Africa\\\"}, \\n HoldPattern[circleneighbors[\\\"Liberia\\\"]] :> \\n \ {\\\"Sierra Leone\\\", \\\"Guinea\\\", \\\"Cote d'Ivoire\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Libya\\\"]] :> \\n {\\\"Tunisia\\\", \ \\\"Algeria\\\", \\\"Niger\\\", \\\"Chad\\\", \\\"Sudan\\\", \\\"Egypt\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Liechtenstein\\\"]] :> \\n \ {\\\"Austria\\\", \\\"Switzerland\\\"}, \ HoldPattern[circleneighbors[\\\"Lithuania\\\"]] :> \\n {\\\"Poland\\\", \ \\\"Belarus\\\", \\\"Latvia\\\", \\\"Russia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Luxembourg\\\"]] :> \\n {\\\"Germany\\\", \ \\\"Belgium\\\", \\\"France\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Macedonia\\\"]] :> \\n {\\\"Serbia and \ Montenegro\\\", \\\"Albania\\\", \\\"Greece\\\", \\\"Bulgaria\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Madagascar\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Malawi\\\"]] :> \\n {\\\"Zambia\\\", \ \\\"Mozambique\\\", \\\"Tanzania\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Malaysia\\\"]] :> \\n {\\\"Thailand\\\", \\\ \"Indonesia\\\", \\\"Brunei\\\"}, \\n HoldPattern[circleneighbors[\\\"Mali\\\ \"]] :> \\n {\\\"Senegal\\\", \\\"Guinea\\\", \\\"Cote d'Ivoire\\\", \ \\\"Burkina\\\", \\\"Niger\\\", \\\"Algeria\\\", \\n \\\"Mauritania\\\"}, \ HoldPattern[circleneighbors[\\\"Mauritania\\\"]] :> \\n {\\\"Western Sahara\ \\\", \\\"Algeria\\\", \\\"Mali\\\", \\\"Senegal\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Mexico\\\"]] :> {\\\"USA\\\", \\\"Guatemala\\\ \", \\\"Belize\\\"}, \\n HoldPattern[circleneighbors[\\\"Moldova\\\"]] :> \ {\\\"Romania\\\", \\\"Ukraine\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Monaco\\\"]] :> {\\\"France\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Mongolia\\\"]] :> {\\\"China\\\", \ \\\"Russia\\\"}, \\n HoldPattern[circleneighbors[\\\"Morocco\\\"]] :> \ {\\\"Algeria\\\", \\\"Western Sahara\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Mozambique\\\"]] :> \\n {\\\"Swaziland\\\", \ \\\"South Africa\\\", \\\"Zimbabwe\\\", \\\"Zambia\\\", \\\"Malawi\\\", \ \\\"Tanzania\\\"}, \\\\\\n\\n HoldPattern[circleneighbors[\\\"Namibia\\\"]] \ :> \\n {\\\"Angola\\\", \\\"Zambia\\\", \\\"Botswana\\\", \\\"South \ Africa\\\", \\\"Zimbabwe\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Nepal\\\"]] :> {\\\"China\\\", \ \\\"India\\\"}, \\n HoldPattern[circleneighbors[\\\"Netherlands\\\"]] :> {\\\ \"Belgium\\\", \\\"Germany\\\"}, \\n HoldPattern[circleneighbors[\\\"New \ Zealand\\\"]] :> {}, \\n HoldPattern[circleneighbors[\\\"Nicaragua\\\"]] :> \ {\\\"Costa Rica\\\", \\\"Honduras\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Niger\\\"]] :> \\n {\\\"Nigeria\\\", \ \\\"Benin\\\", \\\"Burkina\\\", \\\"Mali\\\", \\\"Algeria\\\", \\\"Libya\\\", \ \\\"Chad\\\"}, \\n HoldPattern[circleneighbors[\\\"Nigeria\\\"]] :> \\n \ {\\\"Cameroon\\\", \\\"Chad\\\", \\\"Niger\\\", \\\"Benin\\\"}, \\n \ HoldPattern[circleneighbors[\\\"North Korea\\\"]] :> \\n {\\\"South Korea\\\ \", \\\"Russia\\\", \\\"China\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Norway\\\"]] :> {\\\"Sweden\\\", \ \\\"Finland\\\", \\\"Russia\\\"}, \\n HoldPattern[circleneighbors[\\\"Oman\\\ \"]] :> {\\\"Yemen\\\", \\\"Saudi Arabia\\\", \\\"UAE\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Pakistan\\\"]] :> \\n {\\\"Iran\\\", \ \\\"Afghanistan\\\", \\\"China\\\", \\\"India\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Panama\\\"]] :> {\\\"Colombia\\\", \\\"Costa \ Rica\\\"}, \\n HoldPattern[circleneighbors[\\\"Papua New Guinea\\\"]] :> {\\\ \"Indonesia\\\"}, \\n HoldPattern[circleneighbors[\\\"Paraguay\\\"]] :> \\n \ {\\\"Brazil\\\", \\\"Argentina\\\", \\\"Bolivia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Peru\\\"]] :> \\n {\\\"Ecuador\\\", \ \\\"Colombia\\\", \\\"Brazil\\\", \\\"Bolivia\\\", \\\"Chile\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Philippines\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Poland\\\"]] :> \\n {\\\"Germany\\\", \ \\\"Czech Republic\\\", \\\"Slovakia\\\", \\\"Ukraine\\\", \\\"Belarus\\\", \ \\n \\\"Lithuania\\\", \\\"Russia\\\"}, \ HoldPattern[circleneighbors[\\\"Portugal\\\"]] :> \\n {\\\"Spain\\\"}, \ HoldPattern[circleneighbors[\\\"Puerto Rico\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Qatar\\\"]] :> {\\\"Saudi Arabia\\\", \\\"UAE\ \\\"}, \\n HoldPattern[circleneighbors[\\\"Romania\\\"]] :> \\n \ {\\\"Moldova\\\", \\\"Ukraine\\\", \\\"Hungary\\\", \\\"Serbia and Montenegro\ \\\", \\\"Bulgaria\\\"}, \\n HoldPattern[circleneighbors[\\\"Russia\\\"]] :> \ \\n {\\\"Norway\\\", \\\"Finland\\\", \\\"North Korea\\\", \\\"China\\\", \ \\\"Mongolia\\\", \\\"Kazakhstan\\\", \\n \\\"Georgia\\\", \ \\\"Azerbaijan\\\", \\\"Ukraine\\\", \\\"Belarus\\\", \\\"Latvia\\\", \ \\\"Estonia\\\", \\n \\\"Lithuania\\\", \\\"Poland\\\"}, \ HoldPattern[circleneighbors[\\\"Rwanda\\\"]] :> \\n {\\\"Uganda\\\", \ \\\"Tanzania\\\", \\\"Burundi\\\", \\\"Zaire\\\"}, \\n \ HoldPattern[circleneighbors[\\\"San Marino\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Saudi Arabia\\\"]] :> \\n {\\\"Yemen\\\", \ \\\"Oman\\\", \\\"UAE\\\", \\\"Qatar\\\", \\\"Kuwait\\\", \\\"Jordan\\\", \ \\\"Iraq\\\"}, \\n HoldPattern[circleneighbors[\\\"Senegal\\\"]] :> \\n \ {\\\"The Gambia\\\", \\\"Mauritania\\\", \\\"Mali\\\", \\\"Guinea-Bissau\\\", \ \\\"Guinea\\\"}, \\n HoldPattern[circleneighbors[\\\"Serbia and Montenegro\\\ \"]] :> \\n {\\\"Bosnia and Herzegovina\\\", \\\"Croatia\\\", \\\"Hungary\\\ \", \\\"Romania\\\", \\\"Bulgaria\\\", \\n \\\"Macedonia\\\", \ \\\"Albania\\\"}, HoldPattern[circleneighbors[\\\"Sierra Leone\\\"]] :> \\n \ {\\\"Guinea\\\", \\\"Liberia\\\"}, \ HoldPattern[circleneighbors[\\\"Singapore\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Slovakia\\\"]] :> \\n {\\\"Ukraine\\\", \ \\\"Hungary\\\", \\\"Austria\\\", \\\"Czech Republic\\\", \\\"Poland\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Slovenia\\\"]] :> \\n {\\\"Italy\\\", \ \\\"Austria\\\", \\\"Hungary\\\", \\\"Croatia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Somalia\\\"]] :> \\n {\\\"Kenya\\\", \ \\\"Ethiopia\\\", \\\"Djibouti\\\"}, \\n \ HoldPattern[circleneighbors[\\\"South Africa\\\"]] :> \\n \ {\\\"Swaziland\\\", \\\"Mozambique\\\", \\\"Zimbabwe\\\", \\\"Botswana\\\", \ \\\"Namibia\\\"}, \\n HoldPattern[circleneighbors[\\\"South Korea\\\"]] :> {\ \\\"North Korea\\\"}, \\n HoldPattern[circleneighbors[\\\"Spain\\\"]] :> \\n \ {\\\"Portugal\\\", \\\"Gibraltar\\\", \\\"France\\\", \\\"Andorra\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Sri Lanka\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Sudan\\\"]] :> \\n {\\\"Eritrea\\\", \ \\\"Ethiopia\\\", \\\"Kenya\\\", \\\"Uganda\\\", \\\"Zaire\\\", \\\"CAR\\\", \ \\\"Chad\\\", \\n \\\"Libya\\\", \\\"Egypt\\\"}, \ HoldPattern[circleneighbors[\\\"Suriname\\\"]] :> \\n {\\\"Guyana\\\", \ \\\"Brazil\\\", \\\"French Guiana\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Swaziland\\\"]] :> \\n {\\\"Mozambique\\\", \ \\\"South Africa\\\"}, \\n HoldPattern[circleneighbors[\\\"Sweden\\\"]] :> {\ \\\"Finland\\\", \\\"Norway\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Switzerland\\\"]] :> \\n {\\\"Liechtenstein\ \\\", \\\"Austria\\\", \\\"Germany\\\", \\\"France\\\", \\\"Italy\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Syria\\\"]] :> \\n {\\\"Turkey\\\", \ \\\"Iraq\\\", \\\"Jordan\\\", \\\"Israel\\\", \\\"Lebanon\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Taiwan\\\"]] :> {}, \\n \ HoldPattern[circleneighbors[\\\"Tajikistan\\\"]] :> \\n \ {\\\"Uzbekistan\\\", \\\"Afghanistan\\\", \\\"China\\\", \\\"Kyrgyzstan\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Tanzania\\\"]] :> \\n {\\\"Kenya\\\", \ \\\"Uganda\\\", \\\"Rwanda\\\", \\\"Burundi\\\", \\\"Zaire\\\", \ \\\"Zambia\\\", \\\"Malawi\\\", \\n \\\"Mozambique\\\"}, \ HoldPattern[circleneighbors[\\\"Thailand\\\"]] :> \\n {\\\"Malaysia\\\", \\\ \"Cambodia\\\", \\\"Burma\\\", \\\"Laos\\\"}, \\n \ HoldPattern[circleneighbors[\\\"The Gambia\\\"]] :> {\\\"Senegal\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Togo\\\"]] :> {\\\"Ghana\\\", \ \\\"Burkina\\\", \\\"Benin\\\"}, \\n HoldPattern[circleneighbors[\\\"Tunisia\ \\\"]] :> {\\\"Algeria\\\", \\\"Libya\\\"}, \\n HoldPattern[circleneighbors[\ \\\"Turkey\\\"]] :> \\n {\\\"Syria\\\", \\\"Iraq\\\", \\\"Iran\\\", \ \\\"Armenia\\\", \\\"Azerbaijan\\\", \\\"Georgia\\\", \\\"Greece\\\", \\n \ \\\"Bulgaria\\\"}, HoldPattern[circleneighbors[\\\"Turkmenistan\\\"]] :> \\n \ {\\\"Kazakhstan\\\", \\\"Uzbekistan\\\", \\\"Afghanistan\\\", \\\"Iran\\\"}, \ \\n HoldPattern[circleneighbors[\\\"UAE\\\"]] :> {\\\"Qatar\\\", \\\"Saudi \ Arabia\\\", \\\"Oman\\\"}, \\n HoldPattern[circleneighbors[\\\"Uganda\\\"]] \ :> \\n {\\\"Sudan\\\", \\\"Kenya\\\", \\\"Tanzania\\\", \\\"Rwanda\\\", \ \\\"Zaire\\\"}, \\n HoldPattern[circleneighbors[\\\"Ukraine\\\"]] :> \\n {\ \\\"Moldova\\\", \\\"Romania\\\", \\\"Hungary\\\", \\\"Slovakia\\\", \ \\\"Poland\\\", \\\"Belarus\\\", \\n \\\"Russia\\\"}, \ HoldPattern[circleneighbors[\\\"United Kingdom\\\"]] :> {\\\"Ireland\\\"}, \\\ \\\\n\\n HoldPattern[circleneighbors[\\\"Uruguay\\\"]] :> \ {\\\"Argentina\\\", \\\"Brazil\\\"}, \\n HoldPattern[circleneighbors[\\\"USA\ \\\"]] :> {\\\"Canada\\\", \\\"Mexico\\\"}, \\n HoldPattern[circleneighbors[\ \\\"Uzbekistan\\\"]] :> \\n {\\\"Turkmenistan\\\", \\\"Afghanistan\\\", \ \\\"Tajikistan\\\", \\\"Kyrgyzstan\\\", \\\"Kazakhstan\\\"}, \\\\\\n\\n \ HoldPattern[circleneighbors[\\\"Venezuela\\\"]] :> \\n {\\\"Guyana\\\", \ \\\"Brazil\\\", \\\"Colombia\\\"}, \\n \ HoldPattern[circleneighbors[\\\"Vietnam\\\"]] :> {\\\"China\\\", \ \\\"Laos\\\", \\\"Cambodia\\\"}, \\n HoldPattern[circleneighbors[\\\"Western \ Sahara\\\"]] :> \\n {\\\"Morocco\\\", \\\"Algeria\\\", \\\"Mauritania\\\"}, \ \\n HoldPattern[circleneighbors[\\\"Yemen\\\"]] :> {\\\"Oman\\\", \\\"Saudi \ Arabia\\\"}, \\n HoldPattern[circleneighbors[\\\"Zaire\\\"]] :> \\n \ {\\\"Cabinda\\\", \\\"Congo\\\", \\\"CAR\\\", \\\"Sudan\\\", \\\"Uganda\\\", \ \\\"Rwanda\\\", \\\"Burundi\\\", \\n \\\"Tanzania\\\", \\\"Zambia\\\", \ \\\"Angola\\\"}, \\n HoldPattern[circleneighbors[\\\"Zambia\\\"]] :> \\n {\ \\\"Zaire\\\", \\\"Angola\\\", \\\"Namibia\\\", \\\"Botswana\\\", \ \\\"Zimbabwe\\\", \\\"Mozambique\\\", \\n \\\"Malawi\\\", \ \\\"Tanzania\\\"}, HoldPattern[circleneighbors[\\\"Zimbabwe\\\"]] :> \\n \ {\\\"Mozambique\\\", \\\"South Africa\\\", \\\"Botswana\\\", \\\"Namibia\\\", \ \\\"Zambia\\\"}, \\n HoldPattern[circleneighbors[s_String]] :> \\n \ (circleneighbors[s] = \\n Block[{}, nei = Neighbors[s]; inei = nei; \\n \ If[Length[nei] > 2, nei = \\n Sort[nei, \ Length[Intersection[Neighbors[#1], nei]] < \\n \ Length[Intersection[Neighbors[#2], nei]] & ]; \\n \ If[MemberQ[{\\\"Panama\\\", \\\"Monaco\\\", \\\"Denmark\\\", \\\"Spain\\\"}, \ First[nei]], \\n nei = RotateLeft[nei]]; onei = nei; new = \ {First[nei]}; \\n nei = Rest[nei]; onew = new; \\n Do[nel = \ \\n nhn[iji] = \\n First2[handswitch[HH[iji] = \\n \ Intersection[NN = Neighbors[Last[new]], nei]]]; \\n \ If[nel =!= False, new = Append[new, nel]; \\n nei = Select[nei, \ #1 =!= nel & ]; ]; neiw[iji] = nei; \\n neww[iji] = new, {iji, \ Length[nei] - 1}]; nein = nei; jaja = new; \\n Do[nnn = nei[[j]]; \ If[SameBorderQ[Last[new], nnn], \\n AppendTo[new, Last[nei]], \\n \ Catch[Do[If[SameBorderQ[nnn, new[[jj]]] && \\n \ SameBorderQ[nnn, new[[jj + 1]]], \\n Throw[new = Insert[new, \ nnn, jj + 1]]], \\n {jj, Length[new] - 1}]; \\n \ Do[If[SameBorderQ[nnn, new[[jj]]], \\n Throw[new = Insert[new, \ nnn, jj + 1]]], {jj, Length[new]}]\\\\\\n; \\\\\\nnew = Append[new, nnn]]], \ {j, Length[nei]}]; new, \ nei]])};\\n\\n(*\\nAfrica\\n*)\\nMap[(countrycolor[#]=White)&,Miscellaneous`\ WorldNames`Africa];\\n$ColoringCount = 0;\\n$WrongColorCount = \ 0;\\n$StartTime=.;\\nIf[Head[reno]===NotebookObject, \ NotebookClose[reno]];\\nIf[Head[na]===NotebookObject, \ NotebookClose[na]];\\nIf[Head[nt]===NotebookObject, \ NotebookClose[nt]];\\n$Continent=Miscellaneous`WorldNames`Africa;\\\ nAfricaPlot := \ \\\\\\nMiscellaneous`WorldPlot`WorldPlot[{Miscellaneous`WorldNames`Africa,\\\\\ \\ncountrycolor/@Miscellaneous`WorldNames`Africa},\\nMiscellaneous`WorldPlot`\ WorldBorders->\\n{Dashing[{0.001,0.01}]},Miscellaneous`WorldPlot`WorldGrid->\ None,Miscellaneous`\\\\\\nWorldPlot`WorldFrame->None,\\nMiscellaneous`\ WorldPlot`WorldBackground->RGBColor[0,.8,1]];\\ncowi=10;tt=cp[Miscellaneous`\ WorldNames`Africa]/.fu[w__]:>\\nfuu[w,\\\"Africa\\\"];\\n(*\\nThe country \ palette\\n*)\\nIf[Head[nt] === NotebookObject, \ NotebookClose[nt]];\\nnt=NotebookPut[Notebook[{Cell[BoxForm[tt],\\\ nNotebookDefault,\\nCellTags->\\\"AfricaPalette\\\"]}, \\nscreenrectopt,\\n \ WindowToolbars -> {}, \\n PageWidth -> 651, \\n WindowMargins -> \\n \ {{Automatic, 2}, \\n {Automatic, 19}}, \\n WindowFrame -> \ \\\"Palette\\\", \\n WindowElements -> {}, \\n WindowFrameElements -> \ \\\"CloseBox\\\", WindowClickSelect -> False, \\n WindowTitle -> \\n tra[\\\ \"Click on the black country buttons for a list of neighbors\\\"], \ \\\\\\nScrollingOptions -> \\n {\\\"PagewiseScrolling\\\" -> True}, \\n \ ShowCellBracket -> False, \\n CellMargins -> \\n {{0, 0}, {Inherited, 0}}, \ \\n Active -> True, \\n CellOpen -> True, \\n ShowCellLabel -> False, \\n \ ShowCellTags -> False, \\n WindowSize->{444,576},\\n ImageMargins -> \\n \ {{0, Inherited}, \\n {Inherited, 0}}, \\n Magnification -> \ 1\\n]];\\nSetOptions[nt, WindowMargins\\\\:f522{{Automatic,4}, \\n \ {Automatic, 22}},screenrectopt,WindowSize->{FitAll,FitAll}];\\n(*\\nThe \ Africa map\\n*)\\nIf[Head[na] === NotebookObject, \ NotebookClose[na]];\\nna=NotebookCreate[Background->RGBColor[0,.8,1],\\\ nWindowToolbars->{},\\nPageWidth->865,\\nWindowSize->{557, \ 432},\\nWindowMargins->{{0, Automatic}, {Automatic, \ 0}},\\nWindowFrame->\\\"Palette\\\",\\nWindowElements->{},\\\ nWindowFrameElements->\\\"CloseBox\\\",\\nWindowClickSelect->False,\\\ nScrollingOptions->{\\\"PagewiseScrolling\\\"->True},\\nShowCellBracket->\ False,\\nCellMargins->{{0, 0}, {Inherited, \ 0}},\\nActive->True,\\nCellOpen->True,\\nShowCellLabel->False,\\nShowCellTags-\ >False,\\nImageMargins->{{0, Inherited}, {Inherited, 0}},\\nWindowTitle->tra[\ \\\"Africa\\\"],\\nMagnification-> \ 1.5\\n];\\nSetOptions[na,WindowMargins->{{0, Automatic}, \ {Automatic,15}}];\\nNotebookWrite[na,Cell[\\\"AfricaPlot ;\\\", \ \\\"Input\\\",\\nShowCellLabel->False,ShowCellBracket->False,CellOpen->False]]\ ;\\nplotit;\\n);\\n\""]]], startit[ ]], ButtonEvaluator->Automatic]], "Text", Active->True], Cell[TextData[{ "See also: ", ButtonBox["http://mathworld.wolfram.com/Four-ColorTheorem.html", ButtonData:>{ URL[ "http://mathworld.wolfram.com/Four-ColorTheorem.html"], None}, ButtonStyle->"Hyperlink"] }], "Text"], Cell["The four-color theorem states:", "Text"], Cell[CellGroupData[{ Cell["\<\ Any map in a plane can be colored using four colors in such a way \ that regions sharing a common boundary (other than a single point) do not \ share the same color.\ \>", "Subsubtitle", CellFrame->True, Background->GrayLevel[0.849989]], Cell["\<\ This game is to visualize the theorem interactively: Try to color all countries of Africa in such a way that no two neighboring \ coutries are colored the same.\ \>", "Text"], Cell["\<\ Clicking on the colored squares next to the country names colors \ the respective country. Clicking on the country names gives a list of \ neighboring countries. (Don't click on the map itself! (this might be a \ J/Link exercise to do ...)).\ \>", "Text"], Cell["\<\ Goal of the game is to color the map without making mistakes in \ record time. The needed (wall-clock) time from the first to the last click is \ displayed in the window title bar.\ \>", "Text"], Cell["\<\ As a variation you might want to try to color as few countries as \ possible with, say, yellow.\ \>", "Text"], Cell[TextData[StyleBox["Have fun!!", FontSlant->"Italic"]], "Text"] }, Open ]] }, Open ]] }, FrontEndVersion->"4.2 for Microsoft Windows", ScreenRectangle->{{0, 1600}, {0, 1153}}, WindowSize->{837, 602}, WindowMargins->{{0, Automatic}, {Automatic, 56}}, Magnification->1, StyleDefinitions -> "PrimaryColor.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 65, 1, 90, "Title"], Cell[1844, 56, 243, 7, 43, "Text"], Cell[2090, 65, 142, 4, 38, "SmallText"], Cell[2235, 71, 46, 0, 43, "Text"], Cell[2284, 73, 41712, 615, 51, "Text"], Cell[43999, 690, 232, 6, 43, "Text"], Cell[44234, 698, 46, 0, 43, "Text"], Cell[CellGroupData[{ Cell[44305, 702, 250, 6, 60, "Subsubtitle"], Cell[44558, 710, 184, 4, 67, "Text"], Cell[44745, 716, 265, 5, 67, "Text"], Cell[45013, 723, 204, 4, 67, "Text"], Cell[45220, 729, 119, 3, 43, "Text"], Cell[45342, 734, 69, 1, 43, "Text"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)