Play dominoes using strings
+1
−0
Challenge
Given two lists of strings
Output any
Test cases
Outputs are 1-indexed.
A: ["a", "ab", "bba"]
B: ["baa", "aa", "bb"]
K: [3, 2, 3, 1]
A: ["aa", "ba", "c"]
B: ["a", "ab", "ac"]
K: [1, 2, 2, 3]
A: ["", "", "da", "dc", "db"]
B: ["adbdc", "d", "", "", ""]
K: [2, 1, 3, 5, 4]
The string "bbaabbbaa"
, in the second case is "aababac"
, and in the third case is "dadbdc"
. Note that there may be multiple solutions.
Rules
- Input can be in any format you like (list of strings, list of lists of characters, etc). You can also use list of lists of integers instead of list of strings if you prefer.
- Output can also be in any format you like. List
represents the list of indices of and . It can be 0-indexed or 1-indexed. You can also output the list of pairs instead. - Output is not allowed to contain the calculated string
only (you can output it along with list if you want, but is mandatory). - Output cannot be an empty list.
- In case there are multiple solutions, output any valid solution.
- You can assume that:
and are non-empty and have the same length.- For each
, if then . - At least one solution exists.
- This is code-golf, the shortest program wins.
Sandbox
Any suggestions/improvements?
0 comment threads