chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,54 +1,72 @@
---
id: 5a23c84252665b21eecc7ec5
title: 约瑟夫斯问题
title: Josephus problem
challengeType: 5
videoUrl: ''
forumTopicId: 302294
dashedName: josephus-problem
---
# --description--
[约瑟夫斯问题](<https://en.wikipedia.org/wiki/Josephus problem>)是一个严峻描述的数学难题:$ n $囚犯站在一个圆圈上,顺序编号从$ 0 $到$ n-1 $。一名刽子手沿着圈子走,从囚犯$ 0 $开始,移走每个$ k $囚犯并杀死他。随着过程的继续,圆圈变得越来越小,直到只剩下一个囚犯,然后被释放。例如,如果$ n = 5 $囚犯和$ k = 2 $囚犯被杀的命令我们称之为“杀戮序列”将是1,3,0和4幸存者将是2。鉴于任何$ nk> 0 $ 找出哪个囚犯将成为最后的幸存者。在一个这样的事件中有41个囚犯和每3 <sup></sup>囚犯被杀死($ K = 3 $)。其中有一个聪明的名字约瑟夫斯,他解决了这个问题,站在幸存的位置,并继续讲述这个故事。他是哪个号码?写一个函数,以囚犯的初始数量和'k'作为参数,并返回幸存的囚犯的数量。
[Josephus problem](https://en.wikipedia.org/wiki/Josephus problem) is a math puzzle with a grim description: $n$ prisoners are standing on a circle, sequentially numbered from $0$ to $n-1$.
An executioner walks along the circle, starting from prisoner $0$, removing every $k$-th prisoner and killing him.
As the process goes on, the circle becomes smaller and smaller, until only one prisoner remains, who is then freed.
For example, if there are $n=5$ prisoners and $k=2$, the order the prisoners are killed in (let's call it the "killing sequence") will be 1, 3, 0, and 4, and the survivor will be #2.
Given any $n, k > 0$, find out which prisoner will be the final survivor.
In one such incident, there were 41 prisoners and every 3<sup>rd</sup> prisoner was being killed ($k=3$).
Among them was a clever chap name Josephus who worked out the problem, stood at the surviving position, and lived on to tell the tale.
Which number was he?
# --instructions--
Write a function that takes the initial number of prisoners and 'k' as parameter and returns the number of the prisoner that survives.
# --hints--
`josephus`应该是一个功能。
`josephus` should be a function.
```js
assert(typeof josephus == 'function');
```
`josephus(30,3)`应该返回一个数字。
`josephus(30,3)` should return a number.
```js
assert(typeof josephus(30, 3) == 'number');
```
`josephus(30,3)`应该回`29`
`josephus(30,3)` should return `29`.
```js
assert.equal(josephus(30, 3), 29);
```
`josephus(30,5)`应该返回`3`
`josephus(30,5)` should return `3`.
```js
assert.equal(josephus(30, 5), 3);
```
`josephus(20,2)`应该返回`9`
`josephus(20,2)` should return `9`.
```js
assert.equal(josephus(20, 2), 9);
```
`josephus(17,6)`应该回归`2`
`josephus(17,6)` should return `2`.
```js
assert.equal(josephus(17, 6), 2);
```
`josephus(29,4)`应该返回`2`
`josephus(29,4)` should return `2`.
```js
assert.equal(josephus(29, 4), 2);