如果您投掷3个,6个骰子,则多达3次?答案是一个置换?您将如何设置一个函数来解决此问题?
def permutations(numberof_sides,sum_of_dice)
for i in range(numberof_sides):
for j in range(sum_of_dice):
x= ???
我在这里正确的轨道吗?
def permutations(numberof_sides,sum_of_dice)
for i in range(numberof_sides):
for j in range(sum_of_dice):
x= ???
Am I on the right track here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否回答了您的问题,但是我们可以使用
itertools.permutations
来创建排列列表,然后循环循环以查看它们是否正确总结一个基本示例可能会如下:
edit:edit:修复了评论中的错字
Not sure if this answers your question, but we can use
itertools.permutations
to create the list of permutations, then loop through them to see if they sum up properlyA basic example might look like this:
Edit: fixed typo in comment