Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.22 KB | None | 0 0
  1. s = """USA touches: Canada, Mexico
  2.  
  3. Canada touches: USA
  4.  
  5. Mexico touches: USA, Belize, Guatemala
  6.  
  7. Guatemala touches: Mexico, Belize, El Salvador, Honduras
  8.  
  9. Belize touches: Mexico, Guatemala
  10.  
  11. El Salvador touches: Guatemala, Honduras
  12.  
  13. Honduras touches: Guatemala, El Salvador, Nicaragua
  14.  
  15. Nicaragua touches: Honduras, San Jose
  16.  
  17. San Jose touches: Nicaragua, Panama
  18.  
  19. Panama touches: San Jose, Columbia
  20.  
  21. Columbia touches: Venezuela, Brazil, Peru, Ecuador
  22.  
  23. Venezuela touches: Columbia, Brazil, Guyana
  24.  
  25. Guyana touches: Venezuela, Brazil, Suriname
  26.  
  27. Suriname touches: Guyana, Brazil, French Guiana
  28.  
  29. French Guiana touches: Suriname, Brazil
  30.  
  31. Brazil touches: Columbia, Venezuela, Guyana, Suriname, French Guiana, Peru, Bolivia, Paraguay, Argentina, Uruguay
  32.  
  33. Ecuador touches: Columbia, Peru
  34.  
  35. Peru touches: Ecuador, Columbia, Brazil, Bolivia, Chile
  36.  
  37. Bolivia touches: Peru, Brazil, Paraguay, Argentina, Chile
  38.  
  39. Chile touches: Peru, Bolivia, Argentina
  40.  
  41. Paraguay touches: Bolivia, Brazil, Argentina
  42.  
  43. Argentina touches: Chile, Bolivia, Paraguay, Brazil, Uruguay
  44.  
  45. Uruguay touches: Argentina, Brazil
  46.  
  47. The Bahamas touches:
  48.  
  49. Cuba touches:
  50.  
  51. Jamaica touches:
  52.  
  53. Haiti touches: Dominican Republic
  54.  
  55. Dominican Republic touches: Haiti
  56.  
  57. Puerto Rico touches:
  58.  
  59. Saint Kitts and Nevis touches:
  60.  
  61. Montserrat touches:
  62.  
  63. Guadeloupe touches:
  64.  
  65. Dominica touches:
  66.  
  67. Martinique touches:
  68.  
  69. Saint Vincent touches:
  70.  
  71. Barbados touches:
  72.  
  73. Trinidad and Tobago touches:
  74.  
  75. Greenland touches:
  76.  
  77. Azores touches:
  78.  
  79. Falkland Islands touches:
  80.  
  81. South Georgia touches:
  82.  
  83. Cape Verde touches:
  84.  
  85. Madeira Island touches:
  86.  
  87. Canary Islands touches:
  88.  
  89. Faroe Islands touches:
  90.  
  91. Republic of Ireland touches: United Kingdom
  92.  
  93. United Kingdom touches: Republic of Ireland
  94.  
  95. Svalbard touches:
  96.  
  97. Norway touches: Sweden, Finland, Russia
  98.  
  99. Sweden touches: Norway, Finland
  100.  
  101. Finland touches: Sweden, Norway, Russia
  102.  
  103. Russia touches: Norway, Finland, Estonia, Latvia, Belarus, Ukraine, Turkey, Armenia, Azerbaijan, Kazakhstan, China, Mongolia, North Korea
  104.  
  105. Denmark touches: Germany
  106.  
  107. Estonia touches: Russia, Latvia
  108.  
  109. Latvia touches: Estonia, Russia, Belarus, Lithuania
  110.  
  111. Lithuania touches: Latvia, Belarus, Poland
  112.  
  113. Belarus touches: Lithuania, Latvia, Russia, Ukraine, Poland
  114.  
  115. Germany touches: Luxembourg, Belgium, Netherlands, Denmark, Poland, Czech Republic, Austria, Liechtenstein, Switzerland, France
  116.  
  117. Netherlands touches: Germany, Belgium
  118.  
  119. Belgium touches: France, Netherlands, Germany, Luxembourg
  120.  
  121. Luxembourg touches: France, Belgium, Germany
  122.  
  123. Poland touches: Germany, Lithuania, Belarus, Ukraine, Slovakia, Czech Republic
  124.  
  125. Ukraine touches: Slovakia, Poland, Belarus, Russia, Romania, Moldova, Hungary
  126.  
  127. Czech Republic touches: Germany, Poland, Slovakia, Austria
  128.  
  129. Slovakia touches: Austria, Czech Republic, Poland, Ukraine, Hungary
  130.  
  131. Moldova touches: Ukraine, Romania
  132.  
  133. Romania touches: Hungary, Ukraine, Moldova, Bulgaria, Serbia
  134.  
  135. Hungary touches: Austria, Slovakia, Ukraine, Romania, Serbia, Croatia, Slovenia
  136.  
  137. Austria touches: Liechtenstein, Germany, Czech Republic, Slovakia, Hungary, Slovenia, Italy, Switzerland
  138.  
  139. Liechtenstein touches: Switzerland, Germany, Austria
  140.  
  141. France touches: Belgium, Luxembourg, Germany, Switzerland, Italy, Spain
  142.  
  143. Switzerland touches: France, Germany, Liechtenstein, Austria, Italy
  144.  
  145. Slovenia touches: Italy, Austria, Hungary, Croatia
  146.  
  147. Croatia touches: Slovenia, Hungary, Serbia, Bosnia and Herzegovina
  148.  
  149. Bosnia and Herzegovina touches: Croatia, Serbia, Montenegro
  150.  
  151. Serbia touches: Bosnia and Herzegovina, Croatia, Hungary, Romania, Bulgaria, Macedonia, Albania, Montenegro
  152.  
  153. Bulgaria touches: Serbia, Romania, Turkey, Greece, Macedonia
  154.  
  155. Montenegro touches: Bosnia and Herzegovina, Serbia, Albania
  156.  
  157. Albania touches: Montenegro, Serbia, Macedonia, Greece
  158.  
  159. Macedonia touches: Albania, Serbia, Bulgaria, Greece
  160.  
  161. Italy touches: France, Switzerland, Austria, Slovenia
  162.  
  163. Spain touches: Portugal, France
  164.  
  165. Portugal touches: Spain
  166.  
  167. Greece touches: Albania, Macedonia, Bulgaria, Turkey
  168.  
  169. Turkey touches: Greece, Russia, Armenia, Azerbaijan, Iran, Iraq, Syria
  170.  
  171. Malta touches:
  172.  
  173. Cyprus touches:
  174.  
  175. Armenia touches: Turkey, Russia, Azerbaijan, Iran
  176.  
  177. Azerbaijan touches: Turkey, Armenia, Russia, Iran
  178.  
  179. Kazakhstan touches: Russia, China, Uzbekistan, Turkmenistan
  180.  
  181. Mongolia touches: China, Russia
  182.  
  183. North Korea touches: China, Russia, South Korea
  184.  
  185. South Korea touches: North Korea
  186.  
  187. China touches: Afghanistan, Uzbekistan, Kazakhstan, Russia, Mongolia, North Korea, Vietnam, Laos, Myanmar, India, Bhutan, Nepal, Kashmir
  188.  
  189. Uzbekistan touches: Kazakhstan, China, Afghanistan, Turkmenistan
  190.  
  191. Afghanistan touches: Iran, Turkmenistan, Uzbekistan, China, Kashmir, Pakistan
  192.  
  193. Turkmenistan touches: Kazakhstan, Uzbekistan, Afghanistan, Iran
  194.  
  195. Iran touches: Iraq, Turkey, Azerbaijan, Armenia, Turkmenistan, Afghanistan, Pakistan
  196.  
  197. Iraq touches: Jordan, Syria, Turkey, Iran, Kuwait, Saudi Arabia
  198.  
  199. Syria touches: Lebanon, Turkey, Iraq, Jordan, Israel
  200.  
  201. Lebanon touches: Israel, Syria
  202.  
  203. Israel touches: Egypt, Lebanon, Syria, Jordan
  204.  
  205. Jordan touches: Israel, Syria, Iraq, Saudi Arabia
  206.  
  207. Saudi Arabia touches: Jordan, Iraq, Kuwait, Qatar, United Arab Emirates, Oman, Yemen
  208.  
  209. Kuwait touches: Iraq, Saudi Arabia
  210.  
  211. Qatar touches: Saudi Arabia
  212.  
  213. United Arab Emirates touches: Saudi Arabia, Oman
  214.  
  215. Oman touches: Saudi Arabia, United Arab Emirates, Yemen
  216.  
  217. Yemen touches: Saudi Arabia, Oman
  218.  
  219. Pakistan touches: Iran, Afghanistan, Kashmir, India
  220.  
  221. Kashmir touches: Pakistan, Afghanistan, China, India
  222.  
  223. India touches: Pakistan, Kashmir, Nepal, Bhutan, Myanmar, Bangladesh
  224.  
  225. Nepal touches: India, China
  226.  
  227. Bhutan touches: India, China
  228.  
  229. Bangladesh touches: India, Myanmar
  230.  
  231. Sri Lanka touches:
  232.  
  233. Adaman and Nicobar Islands touches:
  234.  
  235. Myanmar touches: Bangladesh, India, China, Laos, Thailand
  236.  
  237. Thailand touches: Myanmar, Laos, Cambodia, Malaysia
  238.  
  239. Laos touches: Myanmar, China, Vietnam, Cambodia, Thailand
  240.  
  241. Vietnam touches: Laos, China, Cambodia
  242.  
  243. Cambodia touches: Thailand, Laos, Vietnam
  244.  
  245. Malaysia touches: Thailand, Brunei, Indonesia
  246.  
  247. Brunei touches: Malaysia
  248.  
  249. Phillipines touches:
  250.  
  251. Indonesia touches: Malaysia, Papua New Guinea, Australia
  252.  
  253. Papua New Guinea touches: Indonesia
  254.  
  255. Australia touches:
  256.  
  257. Tasmania touches:
  258.  
  259. Japan touches:
  260.  
  261. Guam touches:
  262.  
  263. Solomon Islands touches:
  264.  
  265. Vanuatu touches:
  266.  
  267. Fiji touches:
  268.  
  269. New Caledonia touches:
  270.  
  271. New Zealand touches:
  272.  
  273. Kerguelen Island touches:
  274.  
  275. Heard Island touches:
  276.  
  277. Mauritius touches:
  278.  
  279. Reunion touches:
  280.  
  281. Mayotte touches:
  282.  
  283. Comoros touches:
  284.  
  285. Madagascar touches:
  286.  
  287. Sao Tome touches:
  288.  
  289. Bioko touches:
  290.  
  291. Egypt touches: Libya, Israel, Sudan
  292.  
  293. Libya touches: Algeria, Tunisia, Egypt, Sudan, Chad, Niger
  294.  
  295. Tunisia touches: Algeria, Libya
  296.  
  297. Algeria touches: Western Sahara, Morocco, Tunisia, Libya, Niger, Mali, Mauritania
  298.  
  299. Morocco touches: Western Sahara, Algeria
  300.  
  301. Western Sahara touches: Morocco, Algeria, Mauritania
  302.  
  303. Mauritania touches: Western Sahara, Algeria, Mali, Senegal
  304.  
  305. Senegal touches: The Gambia, Mauritania, Mali, Guinea, Guinea-Bissau
  306.  
  307. The Gambia touches: Senegal
  308.  
  309. Guinea-Bissau touches: Senegal, Guinea
  310.  
  311. Guinea touches: Guinea-Bissau, Senegal, Mali, Cote D'Ivoire, Liberia, Sierra Leone
  312.  
  313. Sierra Leone touches: Guinea, Liberia
  314.  
  315. Liberia touches: Sierra Leone, Guinea, Cote D'Ivoire
  316.  
  317. Cote D'Ivoire touches: Liberia, Guinea, Mali, Burkina Faso, Ghana
  318.  
  319. Mali touches: Senegal, Mauritania, Algeria, Niger, Burkina Faso, Cote D'Ivoire, Guinea
  320.  
  321. Burkina Faso touches: Mali, Niger, Benin, Togo, Ghana, Cote D'Ivoire
  322.  
  323. Ghana touches: Cote D'Ivoire, Burkina Faso, Togo
  324.  
  325. Togo touches: Ghana, Burkina Faso
  326.  
  327. Benin touches: Togo, Burkina Faso, Niger, Nigeria
  328.  
  329. Niger touches: Burkina Faso, Mali, Algeria, Libya, Chad, Nigeria, Benin
  330.  
  331. Nigeria touches: Benin, Niger, Chad, Cameroon
  332.  
  333. Chad touches: Niger, Libya, Sudan, Central African Republic, Cameroon, Nigeria
  334.  
  335. Sudan touches: Chad, Libya, Egypt, Eritrea, Ethiopia, Kenya, Uganda, Democratic Republic of the Congo, Central African Republic
  336.  
  337. Eritrea touches: Sudan, Djibouti, Ethiopia
  338.  
  339. Djibouti touches: Ethiopia, Eritrea, Somalia
  340.  
  341. Ethiopia touches: Sudan, Eritrea, Djibouti, Somalia, Kenya
  342.  
  343. Somalia touches: Kenya, Ethiopia, Djibouti
  344.  
  345. Kenya touches: Uganda, Sudan, Ethiopia, Somalia, Tanzania
  346.  
  347. Uganda touches: Democratic Republic of the Congo, Sudan, Kenya, Tanzania, Rwanda
  348.  
  349. Democratic Republic of the Congo touches: Cabinda, Congo, Central African Republic, Sudan, Uganda, Rwanda, Burundi, Zambia, Angola
  350.  
  351. Central African Republic touches: Cameroon, Chad, Sudan, Democratic Republic of the Congo, Congo
  352.  
  353. Cameroon touches: Nigeria, Chad, Central African Republic, Congo, Gabon, Equatorial Guinea
  354.  
  355. Equatorial Guinea touches: Cameroon, Gabon
  356.  
  357. Gabon touches: Equatorial Guinea, Cameroon, Congo
  358.  
  359. Congo touches: Gabon, Cameroon, Central African Republic, Democratic Republic of the Congo, Cabinda
  360.  
  361. Rwanda touches: Democratic Republic of the Congo, Uganda, Tanzania, Burundi
  362.  
  363. Burundi touches: Democratic Republic of the Congo, Rwanda, Tanzania
  364.  
  365. Tanzania touches: Burundi, Rwanda, Uganda, Kenya, Mozambique, Malawi, Zambia
  366.  
  367. Cabinda touches: Congo, Democratic Republic of the Congo
  368.  
  369. Angola touches: Democratic Republic of the Congo, Zambia, Namibia
  370.  
  371. Zambia touches: Angola, Democratic Republic of the Congo, Tanzania, Malawi, Mozambique, Zimbabwe, Botswana, Namibia
  372.  
  373. Malawi touches: Zambia, Tanzania, Mozambique
  374.  
  375. Mozambique touches: Zimbabwe, Zambia, Malawi, Tanzania, South Africa, Swaziland
  376.  
  377. Zimbabwe touches: Namibia, Zambia, Mozambique, South Africa, Botswana
  378.  
  379. Botswana touches: Namibia, Zambia, Zimbabwe, South Africa
  380.  
  381. Namibia touches: Angola, Zambia, Zimbabwe, Botswana, South Africa
  382.  
  383. South Africa touches: Namibia, Botswana, Zimbabwe, Mozambique, Swaziland, Lesotho
  384.  
  385. Swaziland touches: South Africa, Mozambique
  386.  
  387. Lesotho touches: South Africa"""
  388.  
  389. names = []
  390.  
  391. for row in s.split("\n\n"):
  392. names.append(row.split(" touches:")[0])
  393.  
  394. print "\n".join(names)
  395.  
  396. countries = []
  397.  
  398. for row in s.split("\n\n"):
  399. name = row.split(" touches:")[0]
  400. touching = row.split(" touches:")[1][1:].split(", ")
  401.  
  402. lst = [name]
  403. for t in touching:
  404. if t in names:
  405. lst.append(names.index(t))
  406.  
  407. countries.append(lst)
  408.  
  409. o = "["
  410. for country in countries:
  411. o += "[\"" + country[0] + "\"," + ",".join(map(str, country[1: ])) + "],"
  412.  
  413. print o[:-1] + "]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement