1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/珠玑妙算 [master-mind-lcci].html
2022-03-29 12:43:11 +08:00

14 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>珠玑妙算游戏the game of master mind的玩法如下。</p>
<p>计算机有4个槽每个槽放一个球颜色可能是红色R、黄色Y、绿色G或蓝色B。例如计算机可能有RGGB 4种槽1为红色槽2、3为绿色槽4为蓝色。作为用户你试图猜出颜色组合。打个比方你可能会猜YRGB。要是猜对某个槽的颜色则算一次“猜中”要是只猜对颜色但槽位猜错了则算一次“伪猜中”。注意“猜中”不能算入“伪猜中”。</p>
<p>给定一种颜色组合<code>solution</code>和一个猜测<code>guess</code>,编写一个方法,返回猜中和伪猜中的次数<code>answer</code>,其中<code>answer[0]</code>为猜中的次数,<code>answer[1]</code>为伪猜中的次数。</p>
<p><strong>示例:</strong></p>
<pre><strong>输入:</strong> solution="RGBY",guess="GGRR"
<strong>输出:</strong> [1,1]
<strong>解释:</strong> 猜中1次伪猜中1次。
</pre>
<p><strong>提示:</strong></p>
<ul>
<li><code>len(solution) = len(guess) = 4</code></li>
<li><code>solution</code><code>guess</code>仅包含<code>"R"</code>,<code>"G"</code>,<code>"B"</code>,<code>"Y"</code>这4种字符</li>
</ul>