有没有一种方法可以显示值0-4的5个值的所有可能组合?

huangapple go评论130阅读模式
英文:

Is there a way to show all possible combinations of the values 0-4 for 5 values?

问题

我正在尝试帮助开发一个评分标准,用于确定学生的总成绩,其中有5个作业成绩,分别为A(4)到F(0),没有加号或减号。我想要看到每种可能的组合,不重复(即A、A、A、A、F与F、A、A、A、A视为相同)。最好将它们显示在不同的列中,以便我可以看到它们的平均分。

作业1 作业2 作业3 作业4 作业5 平均分
4 4 4 4 4 4
4 4 4 4 3 3.8
4 4 4 4 2 3.6
4 4 4 4 1 3.4
4 4 4 4 0 3.2

使用上面的表格来扩展并包括所有可能的作业成绩组合。

我尝试使用数组公式与PERMUT函数:=ARRAYFORMULA(PERMUT(5,5)),但它只返回组合的数量,不会将它们打印出来。有没有办法做到这一点?

英文:

I am trying to help develop a grading scale which determines the overall grade for a student with 5 assignments entered in A (4) to F (0) with no plusses or minuses. I would like to see each possible combination with no repeats (i.e. A, A, A, A, F is treated the same as F, A, A, A, A). It would be preferable to have them in separate columns so that I can see their averages.

Assign. 1 Assign. 2 Assign. 3 Assign. 4 Assign. 5 Average
4 4 4 4 4 4
4 4 4 4 3 3.8
4 4 4 4 2 3.6
4 4 4 4 1 3.4
4 4 4 4 0 3.2

With the above table to expand and include all possible combinations of the assignment grades.

I have tried using the array formula with the permut function: =ARRAYFORMULA(PERMUT(5,5)) but it returns the number of combinations but won't print them. Is there a way to do this?

答案1

得分: 0

以下是代码部分的翻译,不包括问题的翻译:

下面的方法效率极低,但确实生成了指定的答案:

assignments,5,
grades,5,
splitdigits,lambda(x,mid(x,sequence(1,assignments),1)),
permuts,base(sequence(grades^assignments,1,0),grades,grades),
splitpermuts,1*splitdigits(permuts),
combos,unique(byrow(splitpermuts,lambda(row,join(,large(row,sequence(1,assignments)))))),
splitcombos,1*splitdigits(combos),
{{"Assign. "&sequence(1,assignments),"Average"};
{splitcombos,byrow(splitcombos,lambda(row,average(row)))}}))```

我们使用一些数学方法生成了每一种成绩的排列组合,然后通过对每一行的成绩进行排序并提取行的唯一列表来提取所有的组合。base/sequence方法来源于TheMaster的回答,链接在这里:https://stackoverflow.com/questions/73752135/how-to-list-all-permutations-without-repetition/73765831#73765831

<details>
<summary>英文:</summary>

The below approach is extremely inefficient but does generate the specified answer:

=arrayformula(let(
assignments,5,
grades,5,
splitdigits,lambda(x,mid(x,sequence(1,assignments),1)),
permuts,base(sequence(grades^assignments,1,0),grades,grades),
splitpermuts,1splitdigits(permuts),
combos,unique(byrow(splitpermuts,lambda(row,join(,large(row,sequence(1,assignments)))))),
splitcombos,1
splitdigits(combos),
{{"Assign. "&sequence(1,assignments),"Average"};
{splitcombos,byrow(splitcombos,lambda(row,average(row)))}}))

We are using some maths to generate every permutation of grades, then extracting all the combinations by sorting the grades per row and taking the unique list of the rows. The base/sequence approach is taken from TheMaster&#39;s answer here: https://stackoverflow.com/questions/73752135/how-to-list-all-permutations-without-repetition/73765831#73765831

</details>



huangapple
  • 本文由 发表于 2023年4月7日 02:41:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75952761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定