【发布时间】:2022-09-27 16:00:12
【问题描述】:
当前帖子是此链接帖子的后续问题:
惊喜!我的问题孩子实际上是为真女神转生 3 排列 - 为一个视频游戏。我认为把它放在交易卡的术语中对外行来说更有意义。对不起。
好的。我弄乱了一个包含 7 个独特怪物的数据集(在视频游戏早期很容易获得的初始集)。它们不能在我的派对中复制,但可以组合成不同的。一开始,视频游戏中只有 8 个可用于怪物的插槽。
这个项目的重点是构建一个“融合链”的所有排列,试图将这些怪物排列成独特的顺序,以便以后在这个链中组合。
它从 A+B 开始,然后清理该列表以从初始配对中消除任何 B+A 场景(融合 A+B 或 B+A 会产生相同的结果)。然后,融合只是将 C、D、E、F、G 和 H(当前已损坏)添加到上一次融合的结果,直到不再有可能的融合(我的队伍中只有一个怪物)。
问题是这样的:排列单元格中的查询或其他函数在尝试列出一次排序 8 个怪物的排列时抛出错误“结果数组太大”——甚至在融合发生之前。我已将问题隔离到这个公式(有点长):
=iferror(if(counta($A$2:$A$13)>=2,arrayformula(query(query(split(flatten(flatten(flatten(flatten(flatten(flatten(
filter($F$2:$F,$F$2:$F<>\"\")&if(counta($A$2:$A$13)>=3,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\"))&if(counta($A$2:$A$13)>=4,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\"))&if(counta($A$2:$A$13)>=5,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\"))&if(counta($A$2:$A$13)>=6,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\"))&if(counta($A$2:$A$13)>=7,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\"))&if(counta($A$2:$A$13)>=8,\",\"&transpose(
filter($A$2:$A$13,$A$2:$A$13<>\"\")),\"\")),\",\"),
\"where Col1 <> Col2\"&
if(counta($A$2:$A$13)>=3,\" and Col1 <> Col3 and Col2 <> Col3\"&
if(counta($A$2:$A$13)>=4,\" and Col1 <> Col4 and Col2 <> Col4 and Col3 <> Col4\"&
if(counta($A$2:$A$13)>=5,\" and Col1 <> Col5 and Col2 <> Col5 and Col3 <> Col5 and Col4 <> Col5\"&
if(counta($A$2:$A$13)>=6,\" and Col1 <> Col6 and Col2 <> Col6 and Col3 <> Col6 and Col4 <> Col6 and Col5 <> Col6\"&
if(counta($A$2:$A$13)>=7,\" and Col1 <> Col7 and Col2 <> Col7 and Col3 <> Col7 and Col4 <> Col7 and Col5 <> Col7 and Col6 <> Col7\"&
if(counta($A$2:$A$13)>=8,\" and Col1 <> Col8 and Col2 <> Col8 and Col3 <> Col8 and Col4 <> Col8 and Col5 <> Col8 and Col6 <> Col8 and Col7 <> Col8\",),),),),),),0),\"where Col1 <>\'\'\",0)),\"not enough data\"),)
该公式查看的第一个范围是以前稳定的形式(F 列):
| unique init pairs |
|---|
| Pixie,Shikigami |
| Kodama,Pixie |
| Hua Po,Pixie |
| Datsue-Ba,Pixie |
| Angel,Pixie |
| Fomorian,Pixie |
| Kodama,Shikigami |
| Hua Po,Shikigami |
| Datsue-Ba,Shikigami |
| Angel,Shikigami |
| Fomorian,Shikigami |
| Hua Po,Kodama |
| Datsue-Ba,Kodama |
| Angel,Kodama |
| Fomorian,Kodama |
| Datsue-Ba,Hua Po |
| Angel,Hua Po |
| Fomorian,Hua Po |
| Angel,Datsue-Ba |
| Datsue-Ba,Fomorian |
| Angel,Fomorian |
它是由我制作的一种“更清洁”公式提供的,但这不是问题所在。
我正在测试的整体输入是这样的(在 A 列中),也是初始对的更清晰公式的输入:
| available |
|---|
| Pixie |
| Shikigami |
| Kodama |
| Hua Po |
| Datsue Ba |
| Angel |
| Fomorian |
| High Pixie |
而且预期的输出……真的很大。这是获得想法的第一行示例(托管在原始工作表的 H2 中):
| A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|
| Pixie | Shikigami | Kodama | Hua Po | Datsue Ba | Angel | Fomorian | High Pixie |
| Pixie | Shikigami | Kodama | Hua Po | Datsue Ba | Fomorian | Angel | High Pixie |
| Pixie | Shikigami | Kodama | Hua Po | Angel | Datsue Ba | Fomorian | High Pixie |
| Pixie | Shikigami | Kodama | Hua Po | Angel | Fomorian | Datsue Ba | High Pixie |
| Pixie | Shikigami | Kodama | Hua Po | Fomorian | Datsue Ba | Angel | High Pixie |
| Pixie | Shikigami | Kodama | Hua Po | Fomorian | Angel | Datsue Ba | High Pixie |
| Pixie | Shikigami | Kodama | Datsue Ba | Hua Po | Angel | Fomorian | High Pixie |
| and so on... |
我目前不知道如何解决这个问题。我想在我的表格中放置至少 8 个起始怪物以进行分析,如果不是完整的 12 个以供游戏结束。
可能有一种比我现有的方式更好、更紧凑的方式来生成这些排列。我可能想启动 Excel 以在我的超级系统上尝试此操作,然后查看它在何处中断脱机。然而,我想要更有效的公式来解决我在 Google 表格中的“数组太大”问题。这是我工作得最好的地方,也是我有许多其他项目的地方。
-
如果您将带有示例输入和输出的表格添加到问题中,您的问题可以得到很大改善。 Tables 是比电子表格更好的选择来显示您的数据结构。如果您共享电子表格,请确保还添加工作表的图像以避免问题结束,因为此处的问题必须是 self contained。 Your email address can also be accessed by the public,当您共享 Google 文件时。
标签: google-sheets google-sheets-formula permutation combinatorics lexicographic-ordering