curriculum/challenges/english/blocks/daily-coding-challenges-python/699c8e045ee7cb94ed2322d5.md
Given a 2D array representing a sequence of dominoes, determine whether it forms a valid chain.
is_valid_domino_chain([[1, 3], [3, 6], [6, 5]]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_valid_domino_chain([[1, 3], [3, 6], [6, 5]]), True)`)
}})
is_valid_domino_chain([[6, 2], [3, 4], [4, 1]]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_valid_domino_chain([[6, 2], [3, 4], [4, 1]]), False)`)
}})
is_valid_domino_chain([[2, 5], [5, 6], [5, 1]]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_valid_domino_chain([[2, 5], [5, 6], [5, 1]]), False)`)
}})
is_valid_domino_chain([[4, 3], [3, 1], [1, 6], [6, 6], [6, 5], [5, 1], [1, 1], [1, 4], [4, 4], [4, 2]]) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_valid_domino_chain([[4, 3], [3, 1], [1, 6], [6, 6], [6, 5], [5, 1], [1, 1], [1, 4], [4, 4], [4, 2]]), True)`)
}})
is_valid_domino_chain([[2, 3], [3, 3], [3, 6], [6, 1], [1, 4], [3, 5], [5, 5], [5, 4], [4, 2], [2, 2]]) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_valid_domino_chain([[2, 3], [3, 3], [3, 6], [6, 1], [1, 4], [3, 5], [5, 5], [5, 4], [4, 2], [2, 2]]), False)`)
}})
def is_valid_domino_chain(dominoes):
return dominoes
def is_valid_domino_chain(dominoes):
for i in range(len(dominoes) - 1):
if dominoes[i][1] != dominoes[i + 1][0]:
return False
return True