dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.2 KiB
2.2 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 699c8e045ee7cb94ed2322d5 | Challenge 214: Domino Chain Validator | 29 | challenge-214 |
--description--
Given a 2D array representing a sequence of dominoes, determine whether it forms a valid chain.
- Each element in the array represents a domino and will be an array of two numbers from 1 to 6, (inclusive).
- For the chain to be valid, the second number of each domino must match the first number of the next domino.
- The first number of the first domino and the last number of the last domino don't need to match anything.
--hints--
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)`)
}})
--seed--
--seed-contents--
def is_valid_domino_chain(dominoes):
return dominoes
--solutions--
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