chore(i18n,learn): processed translations (#44866)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 59e09e6d412c5939baa02d16
|
||||
title: Execute a Markov algorithm
|
||||
title: マルコフアルゴリズム
|
||||
challengeType: 5
|
||||
forumTopicId: 302260
|
||||
dashedName: execute-a-markov-algorithm
|
||||
@ -8,9 +8,9 @@ dashedName: execute-a-markov-algorithm
|
||||
|
||||
# --description--
|
||||
|
||||
Create an interpreter for a [Markov Algorithm](https://en.wikipedia.org/wiki/Markov algorithm "wp: Markov algorithm").
|
||||
[マルコフアルゴリズム](https://en.wikipedia.org/wiki/Markov algorithm "wp: Markov algorithm") のインタプリタを作成します。
|
||||
|
||||
Rules have the syntax:
|
||||
ルールの構文は以下のとおりです。
|
||||
|
||||
<pre>[ruleset] ::= (([comment] | [rule]) [newline]+)*
|
||||
[comment] ::= # {[any character]}
|
||||
@ -18,17 +18,17 @@ Rules have the syntax:
|
||||
[whitespace] ::= ([tab] | [space]) [[whitespace]]
|
||||
</pre>
|
||||
|
||||
There is one rule per line.
|
||||
1行に1つのルールがあります。
|
||||
|
||||
If there is a `.` (period) present before the \[replacement], then this is a terminating rule in which case the interpreter must halt execution.
|
||||
\[replacement] の前に`.` (ピリオド) がある場合、インタプリタが演算を停止する規則があります。
|
||||
|
||||
A ruleset consists of a sequence of rules, with optional comments.
|
||||
ルールセットは、任意のコメントを含む一連のルールで構成されます。
|
||||
|
||||
Rulesets
|
||||
ルールセット
|
||||
|
||||
Use the following tests on entries:
|
||||
以下のテストを入力に使用します。
|
||||
|
||||
**Ruleset 1:**
|
||||
**ルールセット1:**
|
||||
|
||||
<pre># This rules file is extracted from Wikipedia:
|
||||
# <code>http://en.wikipedia.org/wiki/Markov_Algorithm</code>
|
||||
@ -40,11 +40,11 @@ the shop -> my brother
|
||||
a never used -> .terminating rule
|
||||
</pre>
|
||||
|
||||
Sample text of `I bought a B of As from T S.` should generate the output `I bought a bag of apples from my brother.`
|
||||
`I bought a B of As from T S.` というサンプルテキストで、 `I bought a bag of apples from my brother.` が出力されます。
|
||||
|
||||
**Ruleset 2:**
|
||||
**ルールセット2:**
|
||||
|
||||
A test of the terminating rule
|
||||
停止規則のテスト
|
||||
|
||||
<pre># Slightly modified from the rules on Wikipedia
|
||||
A -> apple
|
||||
@ -55,11 +55,11 @@ the shop -> my brother
|
||||
a never used -> .terminating rule
|
||||
</pre>
|
||||
|
||||
Sample text of `I bought a B of As from T S.` should generate `I bought a bag of apples from T shop.`
|
||||
`I bought a B of As from T S.` というサンプルテキストで、 `I bought a bag of apples from T shop.` が出力されます。
|
||||
|
||||
**Ruleset 3:**
|
||||
**ルールセット3:**
|
||||
|
||||
This tests for correct substitution order and may trap simple regexp based replacement routines if special regexp characters are not escaped.
|
||||
これは正しい置換順序をテストします。特別な正規表現文字がエスケープされない場合、単純な正規表現ベースの置換ルーチンをトラップする場合があります。
|
||||
|
||||
<pre># BNF Syntax testing rules
|
||||
A -> apple
|
||||
@ -74,11 +74,11 @@ the shop -> my brother
|
||||
a never used -> .terminating rule
|
||||
</pre>
|
||||
|
||||
Sample text of `I bought a B of As W my Bgage from T S.` should generate `I bought a bag of apples with my money from T shop.`
|
||||
`I bought a B of As W my Bgage from T S.` というサンプルテキストで、 `I bought a bag of apples with my money from T shop.` が出力されます。
|
||||
|
||||
**Ruleset 4:**
|
||||
**ルールセット4:**
|
||||
|
||||
This tests for correct order of scanning of rules, and may trap replacement routines that scan in the wrong order. It implements a general unary multiplication engine. (Note that the input expression must be placed within underscores in this implementation.)
|
||||
これはルールスキャンの正しい順序をテストし、誤った順序でスキャンする置換ルーチンをトラップする場合があります。 一般的な単項乗算エンジンを実装します。 (この実装では、入力式をアンダースコア内に置くことに注意してください。)
|
||||
|
||||
<pre>### Unary Multiplication Engine, for testing Markov Algorithm implementations
|
||||
### By Donal Fellows.
|
||||
@ -110,15 +110,15 @@ _1 -> 1
|
||||
_+_ ->
|
||||
</pre>
|
||||
|
||||
Sample text of `_1111*11111_` should generate the output `11111111111111111111`
|
||||
`_1111*11111_` というサンプルテキストで、`11111111111111111111` が出力されます。
|
||||
|
||||
**Ruleset 5:**
|
||||
**ルールセット5:**
|
||||
|
||||
A simple [Turing machine](http://en.wikipedia.org/wiki/Turing_machine "link: http://en.wikipedia.org/wiki/Turing_machine"), implementing a three-state [busy beaver](http://en.wikipedia.org/wiki/Busy_beaver "link: http://en.wikipedia.org/wiki/Busy_beaver").
|
||||
シンプルな [チューリングマシン](http://en.wikipedia.org/wiki/Turing_machine "link: http://en.wikipedia.org/wiki/Turing_machine")は、3-状態 [ビジービーバー](http://en.wikipedia.org/wiki/Busy_beaver "link: http://en.wikipedia.org/wiki/Busy_beaver")を実装します。
|
||||
|
||||
The tape consists of `0`s and `1`s, the states are `A`, `B`, `C` and `H` (for `H`alt), and the head position is indicated by writing the state letter before the character where the head is. All parts of the initial tape the machine operates on have to be given in the input.
|
||||
このテープは `0`と`1`からなり、状態は `A`、`B`、`C` および`H` (`H`altの場合) であり、先頭の位置は先頭文字の前に状態文字を書くことにより示されます。 マシンが操作する元のテープをすべて入力する必要あります。
|
||||
|
||||
Besides demonstrating that the Markov algorithm is Turing-complete, it also made me catch a bug in the C++ implementation which wasn't caught by the first four rulesets.
|
||||
マルコフアルゴリズムがチューリング完全であることを示すだけでなく、 最初の4つのルールセットでは見つからなかったC++実装のバグを検出することができました。
|
||||
|
||||
<pre># Turing machine: three-state busy beaver
|
||||
#
|
||||
@ -140,41 +140,41 @@ B1 -> 1B
|
||||
1C1 -> H11
|
||||
</pre>
|
||||
|
||||
This ruleset should turn `000000A000000` into `00011H1111000`
|
||||
このルールセットで `000000A000000` が `00011H1111000`に変更されます。
|
||||
|
||||
# --hints--
|
||||
|
||||
`markov` should be a function.
|
||||
`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.")` should return "I bought a bag of apples from my brother.".
|
||||
`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.")` should return "I bought a bag of apples from T shop.".
|
||||
`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.")` should return "I bought a bag of apples with my money from T shop.".
|
||||
`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_")` should return "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"],"")` should return "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]);
|
||||
|
Reference in New Issue
Block a user