英文:
algorithm for making sure everyone is in the same group
问题
在一组 x 人中,您必须选择至少 2 人,其中至少有 1 人保证会被选中加入您的小组,是否可以确保每个人都在同一组中?
尝试将人们排成一个圆圈,并确保每个人选择他们前面和后面的人。
英文:
a group of x people where you have to choose 2 people at least 1 person is guaranteed to be selected to be in your group, is it possible to make sure everyone is in the same group
try to sort people in a circle and make sure everyone selects the person in front of them and behind them
答案1
得分: 1
开始于一个三角形 — 3个人,每个人都选择其他两个人。他们肯定会最终进入同一组,因为至少有两人会被分在同一组,而第三人选择了他们两个。
现在,你可以将任意多的人添加到这个组中。每个新加入的人只需选择已经保证在组中的两个人,然后他们也将被保证进入该组。
英文:
Start with a triangle -- 3 people, each of which selects the other two. They are guaranteed to end up in the same group, because at least 2 of them will be grouped, and the 3rd person selected both of them.
Now you can add as many people to the group as you like. Each new person just has to select 2 people that are already guaranteed to be in the group. and then they will be guaranteed to be in the group as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论