Domino cycle
Tags: Data Structures Algorithms Combinatorics Simulation
Credit: Ilkka Kokkarinen
Difficulty: Easy
Type: Text
Category: Practice
Time Allowed: 15 s
Description:
A single domino tile is represented as a two-tuple of its pip values, such as (2,5) or (6,6). This function should determine whether the given list of tiles forms a cycle so that each tile in the list ends with the exact same pip value that its successor tile starts with, the successor of the last tile being the first tile of the list since this is supposed to be a cycle instead of a chain. Return True if the given list of tiles forms such a cycle, and False otherwise.
Test Case | Input | Expected Output |
---|---|---|
1 | [(3, 5), (5, 2), (2, 3)] | True |
2 | [(4, 4)] | True |
3 | [] | True |
4 | [(2, 6)] | False |
5 | [(5, 2), (2, 3), (4, 5)] | False |
6 | [(4, 3), (3, 1)] | False |
Leave a Comment
Please login to leave a comment.