def plus(arr, n):
return list(map(lambda x: x + 1, arr))
def func():
# we have 7 countries to color
n = 7
matrix = [[0,1,1,1,0,0,1],
[1,0,1,1,0,0,0],
[1,1,0,1,1,0,1],
[1,1,1,0,1,0,1],
[0,0,1,1,0,1,1],
[0,0,0,0,1,0,1],
[1,0,1,1,1,1,0]]
mapColors = []
mapColors = [0] * (n)
color = -1
ok = True
mapColors[0] = 0
for i in range(1, n):
ok = False
color = -1
while ok is not True:
color += 1
ok = True
for j in range(0, i):
if 1 == matrix[j][i] and mapColors[j] == color:
ok = False
mapColors[i] = color
mapColors = plus(mapColors, 1)
print(mapColors)
func()
ZGVmIHBsdXMoYXJyLCBuKToKCiAgICByZXR1cm4gbGlzdChtYXAobGFtYmRhIHg6IHggKyAxLCBhcnIpKQoKZGVmIGZ1bmMoKToKICAgICMgd2UgaGF2ZSA3IGNvdW50cmllcyB0byBjb2xvcgogICAgbiA9IDcKICAgIG1hdHJpeCA9IFtbMCwxLDEsMSwwLDAsMV0sCiAgICAgICAgICAgICAgWzEsMCwxLDEsMCwwLDBdLAogICAgICAgICAgICAgIFsxLDEsMCwxLDEsMCwxXSwKICAgICAgICAgICAgICBbMSwxLDEsMCwxLDAsMV0sCiAgICAgICAgICAgICAgWzAsMCwxLDEsMCwxLDFdLAogICAgICAgICAgICAgIFswLDAsMCwwLDEsMCwxXSwKICAgICAgICAgICAgICBbMSwwLDEsMSwxLDEsMF1dCgogICAgbWFwQ29sb3JzID0gW10KCiAgICBtYXBDb2xvcnMgPSBbMF0gKiAobikKCiAgICBjb2xvciA9IC0xCgogICAgb2sgPSBUcnVlCgogICAgbWFwQ29sb3JzWzBdID0gMAoKICAgIGZvciBpIGluIHJhbmdlKDEsIG4pOgoKICAgICAgICBvayA9IEZhbHNlCgogICAgICAgIGNvbG9yID0gLTEKCiAgICAgICAgd2hpbGUgb2sgaXMgbm90IFRydWU6CgogICAgICAgICAgICAgIGNvbG9yICs9IDEKCiAgICAgICAgICAgICAgb2sgPSBUcnVlCgogICAgICAgICAgICAgIGZvciBqIGluIHJhbmdlKDAsIGkpOgoKICAgICAgICAgICAgICAgICAgaWYgMSA9PSBtYXRyaXhbal1baV0gYW5kIG1hcENvbG9yc1tqXSA9PSBjb2xvcjoKCiAgICAgICAgICAgICAgICAgICAgICBvayA9IEZhbHNlCiAgICAgICAgbWFwQ29sb3JzW2ldID0gY29sb3IKCiAgICBtYXBDb2xvcnMgPSBwbHVzKG1hcENvbG9ycywgMSkKCiAgICBwcmludChtYXBDb2xvcnMpCgpmdW5jKCkK