diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/breadth-first-search.md b/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/breadth-first-search.md index 98d6794dd6..60681153f0 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/breadth-first-search.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/data-structures/breadth-first-search.md @@ -7,7 +7,7 @@ videoUrl: '' # --description-- -到目前为止,我们已经学会了创建图表表示的不同方法。现在怎么办?一个自然的问题是图中任何两个节点之间的距离是多少?输入图遍历算法遍历算法是遍历或访问图中节点的算法。一种遍历算法是广度优先搜索算法。该算法从一个节点开始,首先访问一个边缘的所有邻居,然后继续访问它们的每个邻居。在视觉上,这就是算法正在做的事情。 ![Breadth first search algorithm moving through a tree](https://camo.githubusercontent.com/2f57e6239884a1a03402912f13c49555dec76d06/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f342f34362f416e696d617465645f4246532e676966)要实现此算法,您需要输入图形结构和要启动的节点。首先,您需要了解距起始节点的距离。这个你想要开始你所有的距离最初一些大的数字,如`Infinity` 。这为从起始节点无法访问节点的情况提供了参考。接下来,您将要从开始节点转到其邻居。这些邻居是一个边缘,此时你应该添加一个距离单位到你要跟踪的距离。最后,有助于实现广度优先搜索算法的重要数据结构是队列。这是一个数组,您可以在其中添加元素到一端并从另一端删除元素。这也称为FIFO先进先出数据结构。 +到目前为止,我们已经学会了创建图表表示的不同方法。现在怎么办?一个自然的问题是图中任何两个节点之间的距离是多少?输入图遍历算法遍历算法是遍历或访问图中节点的算法。一种遍历算法是广度优先搜索算法。该算法从一个节点开始,首先访问一个边缘的所有邻居,然后继续访问它们的每个邻居。在视觉上,这就是算法正在做的事情。 ![广度优先搜索算法遍历](https://camo.githubusercontent.com/2f57e6239884a1a03402912f13c49555dec76d06/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f342f34362f416e696d617465645f4246532e676966)要实现此算法,您需要输入图形结构和要启动的节点。首先,您需要了解距起始节点的距离。这个你想要开始你所有的距离最初一些大的数字,如`Infinity` 。这为从起始节点无法访问节点的情况提供了参考。接下来,您将要从开始节点转到其邻居。这些邻居是一个边缘,此时你应该添加一个距离单位到你要跟踪的距离。最后,有助于实现广度优先搜索算法的重要数据结构是队列。这是一个数组,您可以在其中添加元素到一端并从另一端删除元素。这也称为FIFO先进先出数据结构。 # --instructions-- diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md index a577d7253b..0e0ff9f7c9 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md @@ -1,31 +1,31 @@ --- id: 5900f3b31000cf542c50fec6 -title: 'Problem 71: Ordered fractions' +title: '关卡 71:有序分数' challengeType: 5 forumTopicId: 302184 --- # --description-- -Consider the fraction, `n`/`d`, where `n` and `d` are positive integers. If `n`<`d` and HCF(`n`,`d`)=1, it is called a reduced proper fraction. +考虑形如 `n`/`d` 的分数,其中 `n` 和 `d` 均为正整数。如果 `n`<`d`,且最大公约数 HCF(`n`,`d`)=1,则该分数被称为最简真分数。 -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +如果我们将 `d` ≤ 8 的最简真分数构成的集合按大小升序列出,将得到:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8
-It can be seen that 2/5 is the fraction immediately to the left of 3/7. +可以看出 2/5 是 3/7 的直接左邻的分数。 -By listing the set of reduced proper fractions for `d` ≤ 1,000,000 in ascending order of size, find the numerator of the fraction immediately to the left of 3/7. +将所有 `d` ≤ 1,000,000 的最简真分数按大小升序排列,求此时 3/7 直接左邻的分数的分子。 # --hints-- -`orderedFractions()` should return a number. +`orderedFractions()` 应该返回一个数字。 ```js assert(typeof orderedFractions() === 'number'); ``` -`orderedFractions()` should return 428570. +`orderedFractions()` 应该返回 428570。 ```js assert.strictEqual(orderedFractions(), 428570); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md index 4f380baa1d..40c401fe1d 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md @@ -1,31 +1,31 @@ --- id: 5900f3b41000cf542c50fec7 -title: 'Problem 72: Counting fractions' +title: '关卡 72:分数计数' challengeType: 5 forumTopicId: 302185 --- # --description-- -Consider the fraction, `n`/`d`, where n and d are positive integers. If `n`<`d` and HCF(`n`,`d`)=1, it is called a reduced proper fraction. +考虑形如 `n`/`d` 的分数,其中 n 和 d 均为正整数。如果 `n`<`d`,且最大公约数 HCF(`n`,`d`)=1,则该分数被称为最简真分数。 -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +如果我们将 `d` ≤ 8 的最简真分数构成的集合按大小升序列出,将得到:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8
-It can be seen that there are 21 elements in this set. +可以看出该集合中共有 21 个元素。 -How many elements would be contained in the set of reduced proper fractions for `d` ≤ 1,000,000? +求 `d` ≤ 1,000,000 的最简真分数构成的集合中共有多少个元素。 # --hints-- -`countingFractions()` should return a number. +`countingFractions()` 应该返回一个数字。 ```js assert(typeof countingFractions() === 'number'); ``` -`countingFractions()` should return 303963552391. +`countingFractions()` 应该返回 303963552391。 ```js assert.strictEqual(countingFractions(), 303963552391); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md index 0ac7109511..866871696d 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md @@ -1,31 +1,31 @@ --- id: 5900f3b61000cf542c50fec8 -title: 'Problem 73: Counting fractions in a range' +title: '关卡 73:区间内的分数个数' challengeType: 5 forumTopicId: 302186 --- # --description-- -Consider the fraction, `n`/`d`, where n and d are positive integers. If `n`<`d` and HCF(`n`,`d`)=1, it is called a reduced proper fraction. +考虑形如 `n`/`d` 的分数,其中 n 和 d 均为正整数。如果 `n`<`d`,且其最大公约数 HCF(`n`,`d`)=1,则该分数被称为最简真分数。 -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +如果我们将 `d` ≤ 8 的最简真分数构成的集合按大小升序列出,将得到:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8
-It can be seen that there are 3 fractions between 1/3 and 1/2. +可以看出在 1/3 和 1/2 之间有3个分数。 -How many fractions lie between 1/3 and 1/2 in the sorted set of reduced proper fractions for `d` ≤ 12,000? +将 `d` ≤ 12,000 的最简真分数构成的集合排序后,在 1/3 和 1/2 之间有多少个分数? # --hints-- -`countingFractionsInARange()` should return a number. +`countingFractionsInARange()` 应该返回一个数字。 ```js assert(typeof countingFractionsInARange() === 'number'); ``` -`countingFractionsInARange()` should return 7295372. +`countingFractionsInARange()` 应该返回 7295372。 ```js assert.strictEqual(countingFractionsInARange(), 7295372); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md b/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md index 9135fb413c..efbe3533ac 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md @@ -11,48 +11,69 @@ videoUrl: '' 为[马尔可夫算法]( "wp:马尔可夫算法")创建解释器。 -规则具有以下语法: +规则的语法如下: -:: =(( - - - -:: =- >\[。] - -:: =(|)\[] +
[ruleset] ::= (([comment] | [rule]) [newline]+)*
+[comment] ::= # {[any character]}
+[rule] ::= [pattern] [whitespace] -> [whitespace] [.] [replacement]
+[whitespace] ::= ([tab] | [space]) [[whitespace]]
+
每行有一条规则。 -如果有的话**。** (期间)出席之前,那么这是一个终止规则,在这种情况下,解释器必须停止执行。 +如果在 \[replacement] 之前有一个 `.`(句点),那么这就是一个终止规则。在这种情况下,解释器必须停止执行。 -规则集由一系列规则和可选注释组成。 +规则集由一系列规则组成,可能包含一些注释。 规则集 -对条目使用以下测试: +我们会对你提交的代码进行如下测试: -规则集1: +**规则集 1:** -
# This rules file is extracted from Wikipedia:
+
# 此条规则来自 Wikipedia:
 # http://en.wikipedia.org/wiki/Markov_Algorithm
 A -> apple
 B -> bag
 S -> shop
 T -> the
 the shop -> my brother
-a never used -> .terminating rule
+(终止规则) -> .
 
-

示例文本:

I bought a B of As from T S.

应该生成输出:

I bought a bag of apples from my brother.

规则集2:

终止规则的测试

-
# Slightly modified from the rules on Wikipedia
+对于这段文本:
+
+`I bought a B of As from T S.`
+
+应该输出:
+
+`I bought a bag of apples from my brother.`
+
+**规则集 2:**
+
+终止规则的测试
+
+
# 基于 Wikipedia 的规则稍做修改
 A -> apple
 B -> bag
 S -> .shop
 T -> the
 the shop -> my brother
-a never used -> .terminating rule
+(终止规则) -> .
 
-

示例文本:

I bought a B of As from T S.

应该生成:

I bought a bag of apples from T shop.

规则集3:

如果没有转义特殊的正则表达式字符,这将测试正确的替换顺序并可能捕获简单的基于正则表达式的替换例程。

+ +对于这段文本: + +`I bought a B of As from T S.` + +应该输出: + +`I bought a bag of apples from T shop.` + +**规则集 3:** + +这条不仅可以用来测试替换顺序是否正确,还可以测试你的代码中对正则表达式的处理是否完备。如果你的代码没有对正则表达式进行正确的转义处理,那在替换的时候就会出现问题。 +
# BNF Syntax testing rules
 A -> apple
 WWWW -> with
@@ -63,77 +84,124 @@ W -> WW
 S -> .shop
 T -> the
 the shop -> my brother
-a never used -> .terminating rule
+(终止规则) -> .
 
-

示例文本:

I bought a B of As W my Bgage from T S.

应该生成:

I bought a bag of apples with my money from T shop.

规则集4:

这将测试规则扫描的正确顺序,并可能捕获以错误顺序扫描的替换例程。它实现了一般的一元乘法引擎。 (请注意,在此实现中,输入表达式必须放在下划线中。)

 ##一元乘法引擎,用于测试马尔可夫算法实现
-## Donal Fellows。
-一元加法引擎_ + 1  - > _1 +
-1 + 1  - > 11+
-通过将乘法的分裂转换为普通的
-addition1! - >!1
-,! - >!+
-_! - > _
-通过复制左侧,右侧乘以1 * 1  - > x,@ y进行一元乘法
-1x  - > xX
-X, - > 1,1
-X1  - > 1X
-_x  - > _X
-,x  - >,X
-y1  - > 1y
-y_  - > _
-apply1 @ 1  - > x,@ y的下一阶段
-1 @ _  - > @_
-,@ _  - >!_
-++  - > +
-添加终止清除_1  - > 1
-1 + _  - > 1
-_ + _  - >
-

示例文本:

_1111*11111_

应该生成输出:

11111111111111111111

规则集5:

一台简单的图灵机

实施三态繁忙的海狸

磁带由0和1组成,状态为A,B,C和H(对于Halt),并且通过在头部所在的字符之前写入状态字母来指示磁头位置。

必须在输入中给出机器操作的初始磁带的所有部分。

除了证明Markov算法是Turing-complete之外,它还让我抓住了C ++实现中的一个错误,这个错误没有被前四个规则集捕获。

图灵机:三态繁忙的海狸
-状态A,符号0 =>写1,向右移动,新状态BA0  - > 1B
-状态A,符号1 =>写1,向左移动,新状态C0A1  - > C01
-1A1  - > C11
-状态B,符号0 =>写1,向左移动,新状态A0B0  - > A01
-1B0  - > A11
-状态B,符号1 =>写1,向右移动,新状态BB1  - > 1B
-状态C,符号0 =>写1,向左移动,新状态B0C0  - > B01
+
+对于这段文本:
+
+`I bought a B of As W my Bgage from T S.`
+
+应该输出:
+
+`I bought a bag of apples with my money from T shop.` 
+
+**规则集 4:**
+
+这条是用来测试规则扫描的顺序是否正确,并可能捕获以错误顺序扫描的替换例程。这里我们选取了通用的一元乘法引擎(请注意,在此实现中,输入的表达式必须放在两个下划线之间)。
+
+
 ##一元乘法引擎,用于测试马尔可夫算法实现
+### by Donal Fellows
+# 一元加法引擎
+_+1 -> _1+
+1+1 -> 11+
+# 将乘法转换为普通加法
+1! -> !1
+,! -> !+
+_! -> _
+# 一元乘法,左侧为被乘数,右侧为乘数
+1*1 -> x,@y
+1x -> xX
+X, -> 1,1
+X1 -> 1X
+_x -> _X
+,x -> ,X
+y1 -> 1y
+y_ -> _
+# 下一阶段
+1@1 -> x,@y
+1@_ -> @_
+,@_ -> !_
+++ -> +
+# 加法的终止条件
+_1 -> 1
+1+_ -> 1
+_+_ ->
+
+ +对于这段文本: + +`_1111*11111_` + +应该输出: + +`11111111111111111111` + +**规则集5:** + +一台简单的[图灵机](http://en.wikipedia.org/wiki/Turing_machine)包含三个状态的["忙碌海狸"](http://en.wikipedia.org/wiki/Busy_beaver)。纸带由 0 和 1 组成,状态为 A、B、C 和代表终止(Halt)的 H。通过在字符前写状态字母来的方式来指示读写头的位置。机器运行时需要的初始纸带必须通过输入在一开始全部给出。 + +这一规则集除了可以证明 Markov 算法是图灵完备的,它还帮我找出了使用 C++ 完成此题中的一个错误,而且这个错误没有被前四个规则集抓到。 + +
# 图灵机:三个状态的"忙碌海狸"
+# 状态 A,符号 0 => 写入 1,向右移动,新状态 B
+A0 -> 1B
+# 状态 A,符号 1 => 写入 1,向左移动,新状态 C
+0A1 -> C01
+1A1 -> C11
+# 状态 B,符号 0 => 写入 1,向左移动,新状态 A
+0B0 -> A01
+1B0 -> A11
+# 状态 B,符号 1 => 写入 1,向右移动,新状态 B
+B1  - > 1B
+# 状态 C,符号 0 => 写入 1,向左移动,新状态 B
+0C0  - > B01
 1C0  - > B11
-状态C,符号1 =>写1,向左移动,停止0C1  - > H01
+# 状态 C,符号 1 => 写入 1,向左移动,停止
+0C1  - > H01
 1C1  - > H11
-

这个规则集应该转向

000000A000000

00011H1111000

+
+ +这个规则集应将这段输入: + +`000000A000000` + +转换成: + +`00011H1111000` # --hints-- -`markov`是一个功能。 +`markov` 应是一个函数。 ```js assert(typeof markov === 'function'); ``` -`markov(["A -> apple","B -> bag","S -> shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")`应该回复“我从我兄弟那里买了一袋苹果”。 +`markov(["A -> apple","B -> bag","S -> shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")` 应返回 "I bought a bag of apples from my brother."。 ```js assert.deepEqual(markov(rules[0], tests[0]), outputs[0]); ``` -`markov(["A -> apple","B -> bag","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")`应该回来“我从T商店买了一袋苹果。” +`markov(["A -> apple","B -> bag","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")` 应返回 "I bought a bag of apples from T shop."。 ```js assert.deepEqual(markov(rules[1], tests[1]), outputs[1]); ``` -`markov(["A -> apple","WWWW -> with","Bgage -> ->.*","B -> bag","->.* -> money","W -> WW","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As W my Bgage from T S.")`应该返回”我从T商店用我的钱买了一袋苹果。“ +`markov(["A -> apple","WWWW -> with","Bgage -> ->.*","B -> bag","->.* -> money","W -> WW","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As W my Bgage from T S.")` 应返回 "I bought a bag of apples with my money from T shop."。 ```js assert.deepEqual(markov(rules[2], tests[2]), outputs[2]); ``` -`markov(["_+1 -> _1+","1+1 -> 11+","1! -> !1",",! -> !+","_! -> _","1*1 -> x,@y","1x -> xX","X, -> 1,1","X1 -> 1X","_x -> _X",",x -> ,X","y1 -> 1y","y_ -> _","1@1 -> x,@y","1@_ -> @_",",@_ -> !_","++ -> +","_1 -> 1","1+_ -> 1","_+_ -> "],"_1111*11111_")`应返回”11111111111111111111“。 +`markov(["_+1 -> _1+","1+1 -> 11+","1! -> !1",",! -> !+","_! -> _","1*1 -> x,@y","1x -> xX","X, -> 1,1","X1 -> 1X","_x -> _X",",x -> ,X","y1 -> 1y","y_ -> _","1@1 -> x,@y","1@_ -> @_",",@_ -> !_","++ -> +","_1 -> 1","1+_ -> 1","_+_ -> "],"_1111*11111_")` 应返回 "11111111111111111111"。 ```js assert.deepEqual(markov(rules[3], tests[3]), outputs[3]); ``` -`markov(["A0 -> 1B","0A1 -> C01","1A1 -> C11","0B0 -> A01","1B0 -> A11","B1 -> 1B","0C0 -> B01","1C0 -> B11","0C1 -> H01","1C1 -> H11"],"")`应返回”00011H1111000“。 +`markov(["A0 -> 1B","0A1 -> C01","1A1 -> C11","0B0 -> A01","1B0 -> A11","B1 -> 1B","0C0 -> B01","1C0 -> B11","0C1 -> H01","1C1 -> H11"],"")` 应返回 "00011H1111000"。 ```js assert.deepEqual(markov(rules[4], tests[4]), outputs[4]); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/zhang-suen-thinning-algorithm.md b/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/zhang-suen-thinning-algorithm.md index e9c7cb5a05..bca505e935 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/zhang-suen-thinning-algorithm.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/zhang-suen-thinning-algorithm.md @@ -1,13 +1,13 @@ --- id: 594810f028c0303b75339ad7 -title: Zhang-Suen thinning algorithm +title: Zhang-Suen 细化算法 challengeType: 5 forumTopicId: 302347 --- # --description-- -This is an algorithm used to thin a black and white i.e. one bit per pixel images. For example, with an input image of: +这是一个黑白图像(二值图像)的细化算法。 例如,输入图像如下: @@ -31,7 +31,7 @@ This is an algorithm used to thin a black and white i.e. one bit per pixel image ######## ####### ###### ############# ######
-It produces the thinned output: +细化后的输出图像为:
 
@@ -52,9 +52,9 @@ It produces the thinned output:
 
 
-

Algorithm

+

算法

-Assume black pixels are one and white pixels zero, and that the input image is a rectangular N by M array of ones and zeroes. The algorithm operates on all black pixels P1 that can have eight neighbours. The neighbours are, in order, arranged as: +假设黑像素点为 1,白像素点为 0;则输入图像可以用一个 N * M 的矩阵(或数组)来表示,其中,矩阵中的元素只能为 0 或 1。这个算法对所有黑像素点 P1 进行操作。每个点 P1 都可以有 8 个相邻的点,分别是: @@ -62,70 +62,70 @@ Assume black pixels are one and white pixels zero, and that the input image is a
P9P2P3
P7P6P5
-Obviously the boundary pixels of the image cannot have the full eight neighbours. +显然,对于图像边框上的像素点,与它们相邻的点的数量是小于 8 的。 -

Step 1:

+

步骤一:

-All pixels are tested and pixels satisfying all the following conditions (simultaneously) are just noted at this stage. +选出同时满足以下列出条件的所有像素点:
    -
  1. The pixel is black and has eight neighbours
  2. +
  3. 像素点为黑色,且有 8 个点与之相邻
  4. $2 <= B(P1) <= 6$
  5. $A(P1) = 1$
  6. -
  7. At least one of P2, P4 and P6 is white
  8. -
  9. At least one of P4, P6 and P8 is white
  10. +
  11. P2, P4 and P6 中至少有一个是白点
  12. +
  13. P4, P6 and P8 中至少有一个是白点
-After iterating over the image and collecting all the pixels satisfying all step 1 conditions, all these condition satisfying pixels are set to white. +在对图像进行迭代并选出所有符合这一步所述条件的点后,把这些点都设置为白色。 -

Step 2:

+

步骤二:

-All pixels are again tested and pixels satisfying all the following conditions are just noted at this stage. +选出同时满足以下列出条件的所有像素点:
    -
  1. The pixel is black and has eight neighbours
  2. +
  3. 像素点为黑色,且有 8 个点与之相邻
  4. $2 <= B(P1) <= 6$
  5. $A(P1) = 1$
  6. -
  7. At least one of P2, P4 and P8 is white
  8. -
  9. At least one of P2, P6 and P8 is white
  10. +
  11. P2, P4 and P6 中至少有一个是白点
  12. +
  13. P2, P6 and P8 中至少有一个是白点
-After iterating over the image and collecting all the pixels satisfying all step 2 conditions, all these condition satisfying pixels are again set to white. +在对图像进行迭代并选出所有符合这一步所述条件的点后,把这些点都设置为白色。 -

Iteration:

+

迭代:

-If any pixels were set in this round of either step 1 or step 2 then all steps are repeated until no image pixels are so changed. +只要在步骤一或步骤二,有黑色点被选出并设置成了白色,则继续重复步骤一和步骤二,直到没有黑色点被选出并更改为止。 # --instructions-- -Write a routine to perform Zhang-Suen thinning on the provided image matrix. +基于输入图像(以矩阵的形式给出),实现 Zhang-suen 细化算法。 # --hints-- -`thinImage` should be a function. +`thinImage` 应为函数。 ```js assert.equal(typeof thinImage, 'function'); ``` -`thinImage` should return an array. +`thinImage` 应返回数组。 ```js assert(Array.isArray(result)); ``` -`thinImage` should return an array of strings. +`thinImage` 应返回字符串数组。 ```js assert.equal(typeof result[0], 'string'); ``` -`thinImage` should return an array of strings. +`thinImage` 应返回预计的结果。 ```js assert.deepEqual(result, expected); diff --git a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md index 1a10eeb4aa..a9acc08202 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md +++ b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/execute-a-markov-algorithm.md @@ -107,7 +107,8 @@ _+1 -> _1+ 1! -> !1 ,! -> !+ _! -> _ -# Unary multiplication by duplicating left side, right side times1*1 -> x,@y +# Unary multiplication by duplicating left side, right side times +1*1 -> x,@y 1x -> xX X, -> 1,1 X1 -> 1X @@ -115,11 +116,13 @@ _x -> _X ,x -> ,X y1 -> 1y y_ -> _ -# Next phase of applying1@1 -> x,@y +# Next phase of applying +1@1 -> x,@y 1@_ -> @_ ,@_ -> !_ ++ -> + -# Termination cleanup for addition_1 -> 1 +# Termination cleanup for addition +_1 -> 1 1+_ -> 1 _+_ ->