freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-298-selective-amnes...

28 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 5900f4971000cf542c50ffa9
title: 问题298选择性健忘症
challengeType: 5
videoUrl: ''
---
# --description--
拉里Larry和罗宾Robin玩着一场记忆游戏其中涉及一个随机数序列介于1到10之间含1和10每次被召唤一个。每个玩家最多可以记住5个先前的数字。当被叫号码在玩家的记忆中时该玩家将获得积分。如果不是则播放器将被叫号码添加到他的记忆中如果他的记忆已满则删除另一个号码。
两位选手都以空洞的回忆开始。两位玩家总是向他们的记忆中添加新的遗漏号码,但是在决定删除哪个号码时使用不同的策略: 拉里Larry的策略是删除最长时间内未拨打的电话。 Robin的策略是删除内存中时间最长的数字。
范例游戏Turn 被叫号码 拉里的记忆 拉里的比分 罗宾的记忆 罗宾的分数 1个 1个 1个 0 1个 0 2 2 1,2 0 1,2 0 3 4 1,2,4 0 1,2,4 0 4 6 1,2,4,6 0 1,2,4,6 0 5 1个 1,2,4,6 1个 1,2,4,6 1个 6 8 1,2,4,6,8 1个 1,2,4,6,8 1个 7 10 1,4,6,8,10 1个 2,4,6,8,10 1个 8 2 1,2,6,8,10 1个 2,4,6,8,10 2 9 4 1,2,4,8,10 1个 2,4,6,8,10 3 10 1个 1,2,4,8,10 2 1,4,6,8,10 3
用L表示拉里的分数用R表示罗宾的分数| L-R |的期望值是多少? 50转后使用x.xxxxxxxx格式将答案四舍五入到小数点后八位。
# --hints--
`euler298()`应该返回1.76882294。
```js
assert.strictEqual(euler298(), 1.76882294);
```
# --solutions--