瀏覽代碼

Tidied 'Generate De Bruijn Sequence' operation

n1474335 2 年之前
父節點
當前提交
d102e1b15c

+ 3 - 5
src/core/operations/GenerateDeBruijnSequence.mjs

@@ -4,8 +4,8 @@
  * @license Apache-2.0
  */
 
-import Operation from "../Operation";
-import OperationError from "../errors/OperationError";
+import Operation from "../Operation.mjs";
+import OperationError from "../errors/OperationError.mjs";
 
 /**
  * Generate De Bruijn Sequence operation
@@ -58,9 +58,7 @@ class GenerateDeBruijnSequence extends Operation {
             throw new OperationError("Too many permutations, please reduce k^n to under 50,000.");
         }
 
-        const a = [];
-        for (let i = 0; i < k * n; i++) a.push(0);
-
+        const a = new Array(k * n).fill(0);
         const sequence = [];
 
         (function db(t = 1, p = 1) {

+ 3 - 3
tests/operations/tests/GenerateDeBruijnSequence.mjs

@@ -5,11 +5,11 @@
  * @copyright Crown Copyright 2017
  * @license Apache-2.0
  */
-import TestRegister from "../TestRegister";
+import TestRegister from "../TestRegister.mjs";
 
 TestRegister.addTests([
     {
-        name: "Small Sequence",
+        name: "Generate De Bruijn Sequence: Small Sequence",
         input: "",
         expectedOutput: "00010111",
         recipeConfig: [
@@ -20,7 +20,7 @@ TestRegister.addTests([
         ]
     },
     {
-        name: "Long Sequence",
+        name: "Generate De Bruijn Sequence: Long Sequence",
         input: "",
         expectedOutput: "0000010000200003000110001200013000210002200023000310003200033001010010200103001110011200113001210012200123001310013200133002010020200203002110021200213002210022200223002310023200233003010030200303003110031200313003210032200323003310033200333010110101201013010210102201023010310103201033011020110301111011120111301121011220112301131011320113301202012030121101212012130122101222012230123101232012330130201303013110131201313013210132201323013310133201333020210202202023020310203202033021030211102112021130212102122021230213102132021330220302211022120221302221022220222302231022320223302303023110231202313023210232202323023310233202333030310303203033031110311203113031210312203123031310313203133032110321203213032210322203223032310323203233033110331203313033210332203323033310333203333111112111131112211123111321113311212112131122211223112321123311312113131132211323113321133312122121231213212133122131222212223122321223312313123221232312332123331313213133132221322313232132331332213323133321333322222322233223232233323233233333",
         recipeConfig: [