从Mathematica到Python

发布于 2025-02-06 21:12:00 字数 490 浏览 2 评论 0原文

就像:

SetPartitions[Table[i, {i, 2, 5}]]

。上面代码的输出是:{{{2,3,4,5}},{{2},{3,4,5}},{2,3},{4,5} },{{2,4,5},{3}},{{2,3,4},{5}},{2,5},{3,4}},{2,3,{2,3, 5},{4}},{{2,4},{3,5}},{{2},{3},{4,5}},{2},{2},{3,4},{ 5}},{{2},{3,5},{4}},{{2,3},{4},{5}},{5}},{2,4},{3},{3},{5},{5} },{{2,5},{3},{4}},{{2},{3},{4},{5}}}}}}> 。我想在Python中具有这样的输出。我知道这里提出了许多固定的分区问题,但是,没有人能与Mathematica中的订购完全相同。这是类似的概括

SetPartitions[Table[i, {i, a, b}]]

I have an ordered set partitioning function in Mathematica, just like:

SetPartitions[Table[i, {i, 2, 5}]]

. The output of the above code is:{{{2, 3, 4, 5}}, {{2}, {3, 4, 5}}, {{2, 3}, {4, 5}}, {{2, 4, 5}, {3}}, {{2, 3, 4}, {5}}, {{2, 5}, {3, 4}}, {{2, 3, 5}, {4}}, {{2, 4}, {3, 5}}, {{2}, {3}, {4, 5}}, {{2}, {3, 4}, {5}}, {{2}, {3, 5}, {4}}, {{2, 3}, {4}, {5}}, {{2, 4}, {3}, {5}}, {{2, 5}, {3}, {4}}, {{2}, {3}, {4}, {5}}}
. And I want to have exactly the same output like this in Python. I know there are many set partition questions asked here, but, none could give the exact same ordering as in Mathematica. The generalization of this is something like

SetPartitions[Table[i, {i, a, b}]]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文