洗牌清单 [英] Shuffle the list

查看:55
本文介绍了洗牌清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个清单

1)apple = 10,orange = 10,grape = 5,mango = 13,peach = 20

1) apple = 10, orange = 10, grapes = 5, mango = 13, peach = 20

我希望洗牌的方式是没有水果必须在列表中重复两次

i want the shuffle in a way that no fruit has to repeat twice in the list

喜欢>>苹果,橘子,葡萄,苹果,桃,葡萄,芒果   或任何订单

like>> apple,orange,grape,apple,peach,grape,mango   or any order

2)Ball = 45,bat = 5,cake = 8,net = 7,rocket = 6

2) Ball = 45, bat = 5, cake = 8, net = 7, rocket = 6

这里洗牌球可以出现两次但不总是,洗牌不应该让其他对象重复两次也应该

here in shuffling ball can appear twice but not always, and shuffling should not have other object repeat twice also it should

在下次洗牌时没有再次使用最后一个对象。 

not have the last object again in the next shuffle. 

喜欢>>球,蝙蝠,球,球,蛋糕,净,球,火箭    ----> okie

like >> ball,bat,ball,ball,cake,net,ball,rocket   ----> okie

ball, bat ,ball,ball, bat < /跨度>,净,球,火箭&NBSP; &NBSP; ---->蝙蝠再次来到第二和第五,它不会来,球可以一些,因为它有更多的计数

ball,bat,ball,ball,bat,net,ball,rocket   ----> bat comes again in 2nd and 5th it shuld not come, ball can some since it have more count

请帮助我如何归档洗牌

谢谢

推荐答案

这显然是一个课程作业,旨在帮助您学习如何编程。帮助您的最佳方式是支持您自己做的努力。你应该尽可能多地做,然后提出具体问题,而不是希望我们将
做所有这些。

This is obviously a class assignment that is intended to help you learn how to program. The best way to help you is to support your effort to do it yourself. You should do as much as you can and then ask specific questions instead of hoping that we will do all of it.

问题似乎与甲板相同卡被洗牌;每张卡片的存在永远不会超过一个。

The problem seems to be the same as if a deck of cards is shuffled; there can never be more than one existence of each card.

这是一个提示。您可以创建一个从列表和一个列表,或者您可以将它们称为未洗牌列表和随机列表。程序可以从未洗牌中随机选择一个项目,然后将其从该列表中删除并将其添加到洗牌列表中。因此,尝试编写
程序来执行此操作并向我们展示您所拥有的内容,然后我们可以帮助解决特定问题。

Here is a hint. You can create a from-list and a to-list, or you could call them an unshuffled list and shuffled list. The program can randomly pick an item from the unshuffled and remove it from that list and add it to the shuffled list. So try to write a program to do that and show us what you have and then we can help with specific problems.


这篇关于洗牌清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆