黑盒计数到 19,只有 2 位,并且只能切换?

发布于 2024-09-25 05:09:21 字数 682 浏览 4 评论 0原文

有同学在另一个网站上提问,但没有得到答案。我尝试过几次,但发现它非常棘手。

仅使用开关来完成此操作将需要 9:1 的压缩比,因此我认为技巧很大程度上在于您分配给学生的规则中。也许每个学生都需要一套不同的规则?

我考虑过在没有答案的情况下允许多次迭代,只按照正确的顺序关注学生。我还考虑过将学生编号编码为二进制,并将其与开关中的位相结合,以获得更多位来使用,但这仍然是一个压缩/验证问题:即使其中一个位用于奇偶校验,您仍然有很大的可能出现误报。

如果没有某种方法可以做到这一点,大概就不会提出这个问题。也许这是计算机科学课程中的常见问题并且众所周知?无论如何,言归正传……

“这是我在计算机课上遇到的一个问题。对我来说这似乎是数学问题,并且可能涉及二进制代码。我不确定,我所有的想法都会导致死胡同。

十九学生们有机会通过玩游戏来赢得奖品。经过一段时间来决定策略后,所有学生将被安置在完全无法交流的单独的隔音室中。

游戏的玩法如下。一个房间里有两个电灯开关,每次我都会带学生进入这个房间,然后他或她必须打开其中一个开关。最终被带入房间,但有些学生可能会被带入不止一次,

如果一个人正确地告诉我每个人都在房间里,那么每个人都赢得了奖品。但是,如果有人错误地告诉我每个人都去过房间。然后每个人都会在房间里喂鳄鱼!请注意,要么所有学生都获奖,要么所有人都输。

你的任务是确定一个策略,确保每个人都能赢得奖品(并且不被鳄鱼吃掉)。”

Some student asked this on another site, but got no answers. I had a few stabs at it, but found it pretty tricky.

Doing it with just the switches would require a 9:1 compression ratio, so I guess the trick is very much in the rules you assign to students. Perhaps every student needs a different set of rules?

I've thought about allowing many iterations where no answer comes up, by only paying attention to students in the correct sequence. I've also thought about encoding the student number as binary, and combining that with the bits from the switches, to get more bits to work with, but that's still a compression/validation problem: even if one of those bits was used for parity, you'd still have a big potential for false positives.

Presumably the problem wouldn't have been asked if there wasn't some way to do it. Maybe this is a common problem in comp-sci courses and well-known? Anyway, without further ado...

"Here is a problem I have for a computer class. It's seems kind of mathematical to me and could possibly involve the binary code. I'm not sure, all my ideas lead to dead ends.

Nineteen students are given the opportunity to win a prize by playing a game. After some time to decide on a strategy, all the students will be placed into separate soundproof isolation chambers with absolutely no way to communicate.

The game is played as follows. There are two light switches in a room that will begin in the "off" position. I will bring students into this room one at a time. Each time a student enters the room then he or she must flip one of the switches. All the students will eventually be brought into the room, but some students may be brought in more than one time.

If one person correctly tells me that everyone has been in the room, then everyone wins the prize. However, if someone incorrectly tells me that everyone has been in the room then everyone will be fed to the alligators! Note that either all the students win the prize or else everyone loses.

Your task is to determine a strategy that will be sure to allow everyone to win the prize (and not be eaten by alligators)."

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪 2024-10-02 05:09:21

这听起来像是囚犯和电灯开关之谜的变体,其中一名囚犯被指定为“计数器”,其他人仅“增加计数”一次。

据推测,计数器会打开一个开关,如果你从未被统计过,你会关闭该开关;另一个开关将是“垃圾”。一旦柜台关掉开关18次,他就知道其他所有学生都已经到过这个房间。

This sounds like a variation of the Prisoners and the Light Switch riddle, where one prisoner is designated as a "counter" and everyone else "increments their count" only once.

Presumably the counter would turn on one switch, and if you had never been counted, you would turn off that switch; the other switch would be "garbage". Once the counter turned off the switch 18 times, he knows that all other students have been to the room.

野生奥特曼 2024-10-02 05:09:21

按照问题的措辞方式,组织者/老师可以确保他永远不必颁发奖品:允许每个学生依次进入房间 - 这只允许计数器计算另一名学生。然后只迭代一部分学生 - 比如说其中 3 个。

然后,要么计数器可以数到另外两名学生,然后被卡住,要么计数器永远不会回到房间。

这满足指定的条件:每个人至少进入房间一次,而有些学生则多次进入。

为了让学生获胜,您需要添加一个条件,即任何单个学生访问交换机室之间都有有限限制。

The way the problem is worded, the organizer/teacher can ensure he never has to give out the prize: Allow each student into the room in turn - which only allows the Counter to count one other student. Then only iterate a subset of the students - say 3 of them.

Then either the Counter can count two other students then get stuck, or the Counter never goes back into the room.

This satisfies the specified conditions: Everyone goes into the room at least once, and some students go in multiple times.

To allow the students to win, you need to add the condition that there is a finite limit between any single student's visits to the switch room.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文