任务
给定两个字符列表,输出其笛卡尔积,即,第一个列表中每个字母与第二个列表中每个字母的配对列表。
例
"123456"
并"abcd"
给出:
[["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d"],["4","a"],["4","b"],["4","c"],["4","d"],["5","a"],["5","b"],["5","c"],["5","d"],["6","a"],["6","b"],["6","c"],["6","d"]]
输入值
两个字符或字符串列表。所使用的字符将是字母数字字符,a-z, A-Z, 0-9
并且一个字符可以出现两次,并且可以同时出现在两个输入中。
输出量
输入列表的笛卡尔积。即,列出来自第一列表的字符和来自第二列表的字符的每个可能有序对的列表。每对都是两个字符或两个长度为一的字符串的列表或字符串或类似内容。输出的长度将等于输入长度的乘积。
对必须按顺序列出;首先列出第一个列表的第一个字符与第二个列表的第一个,然后是第一个列表的第一个字符的所有配对。最后一对由第一个列表的最后一个字符和第二个列表的最后一个字符组成。
输出必须是对的平面列表;不是2D矩阵,其中按对的第一个或第二个元素进行分组。
测试用例
inputs output
"123456", "abcd" [["1","a"],["1","b"],["1","c"],["1","d"],["2","a"],["2","b"],["2","c"],["2","d"],["3","a"],["3","b"],["3","c"],["3","d"],["4","a"],["4","b"],["4","c"],["4","d"],["5","a"],["5","b"],["5","c"],["5","d"],["6","a"],["6","b"],["6","c"],["6","d"]]
"abc", "123" [["a","1"],["a","2"],["a","3"],["b","1"],["b","2"],["b","3"],["c","1"],["c","2"],["c","3"]]
"aa", "aba" [["a","a"],["a","b"],["a","a"],["a","a"],["a","b"],["a","a"]]
["1a", "1b", "1c", "2a", "2b", "2c", "3a", "3b", "3c"]
有效的输出格式?