From a0872546b8ff8a214579e802dbb5e7efe9f95db5 Mon Sep 17 00:00:00 2001 From: bilal Date: Sat, 17 Jan 2026 21:21:15 +0300 Subject: [PATCH 1/8] create folder with a file for script and file for user stories for the prototype --- fullstack-cert/js-projects/lab-signal-pattern-detector/script.js | 0 .../js-projects/lab-signal-pattern-detector/user-stories.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 fullstack-cert/js-projects/lab-signal-pattern-detector/script.js create mode 100644 fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md b/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md new file mode 100644 index 000000000..e69de29bb From 7c20ebe7b744cd24aae40deb5939f28a9d760669 Mon Sep 17 00:00:00 2001 From: bilal Date: Mon, 26 Jan 2026 15:10:23 +0300 Subject: [PATCH 2/8] Create user stories --- .../user-stories.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md b/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md index e69de29bb..e3c58e6e9 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md @@ -0,0 +1,19 @@ +In this lab, you will create a function that accepts binary signal sequences and find the motif, mirror patterns, and missing frame in each sequence. + +**Binary Signal Sequence**: An array of 0s and 1s + +**Motif**: A repeating pattern. For example, this sequence `[1, 0, 0, 1, 1, 0, 1, 0, 0, 1]` has this pattern `1, 0, 0, 1` repeated twice. So this pattern is considered a motif. + +**Mirror Pattern**: A pattern that consists of a porition and the symetrical mirror version of that portion immediately after it. For example, this sequence `[0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]` has a mirror pattern, `[1, 0, 0, 1, 1, 0, 0, 1]`. The first portion, `1, 0, 0, 1`, when reversed from right to left gives the second portion, `1, 0, 0, 1`, which is the same as the first portion. + +**Missing Frame**: A frame in the sequence that is neither 0 or 1. + +**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories**: + +1. You should accept an array of signal sequences (each sequence is an array of 0s and 1s). +2. You should implement `findMotif(sequence, motifLength)` using nested loops with early exit flags. +3. You should implement `detectMirror(sequence)` that compares mirrored indices and reports mismatches. +4. You should implement `findMissingFrames(sequence)` that logs gaps in expected binary patterns. +5. You should aggregate results into `{ motifPositions, mirrorsBroken, missingFrames }` for each sequence. From 5b888d31f2904816204bcc81c1db958832c7b3a9 Mon Sep 17 00:00:00 2001 From: bilal Date: Tue, 27 Jan 2026 22:21:49 +0300 Subject: [PATCH 3/8] write findMotif function --- .../lab-signal-pattern-detector/script.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js index e69de29bb..bae0ea9f5 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js @@ -0,0 +1,34 @@ +function findMotif(sequence, motifLength) { + const motifPositions = [] + + if (sequence.length <= 1) { + return [] + } + + if (motifLength <= 1) { + return [] + } + if (sequence.length <= motifLength) { + return [] + } + + for (let i = 0; i <= sequence.length - motifLength; i++) { + for (let j = i + 1; j <= sequence.length - motifLength; j++) { + let match = true + + for (let k = 0; k < motifLength; k++) { + if (sequence[i + k] !== sequence[j + k]) { + match = false + break + } + } + + if (match) { + motifPositions.push(i) + break + } + } + } + + return motifPositions +} From 81a0865fbbd656a8b8a8c7dd56b895b20b292deb Mon Sep 17 00:00:00 2001 From: bilal Date: Fri, 30 Jan 2026 00:01:47 +0300 Subject: [PATCH 4/8] write detectMirror function --- .../lab-signal-pattern-detector/script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js index bae0ea9f5..9ac0b5291 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js @@ -32,3 +32,17 @@ function findMotif(sequence, motifLength) { return motifPositions } + +function detectMirror(sequence) { + const mirrorsBroken = [] + + for (let i = 0; i < Math.floor(sequence.length / 2); i++) { + const mirrorIndex = sequence.length - 1 - i + + if (sequence[i] !== sequence[mirrorIndex]) { + mirrorsBroken.push(i) + } + } + + return mirrorsBroken +} From 12f2e24d02f159c0874abde4dcfd715fefba77ea Mon Sep 17 00:00:00 2001 From: bilal Date: Fri, 30 Jan 2026 01:14:10 +0300 Subject: [PATCH 5/8] write findMissingFrames function --- .../lab-signal-pattern-detector/script.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js index 9ac0b5291..ab63d33e5 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js @@ -1,17 +1,6 @@ function findMotif(sequence, motifLength) { const motifPositions = [] - if (sequence.length <= 1) { - return [] - } - - if (motifLength <= 1) { - return [] - } - if (sequence.length <= motifLength) { - return [] - } - for (let i = 0; i <= sequence.length - motifLength; i++) { for (let j = i + 1; j <= sequence.length - motifLength; j++) { let match = true @@ -46,3 +35,17 @@ function detectMirror(sequence) { return mirrorsBroken } + +function findMissingFrames(sequence, pattern) { + const missingFrames = [] + + for (let i = 0; i < sequence.length; i++) { + const expectedFrame = pattern[i % pattern.length] + + if (sequence[i] !== expectedFrame) { + missingFrames.push(i) + } + } + + return missingFrames +} From 122594aed25a2b61fbc92fa2c9636b6ae3712222 Mon Sep 17 00:00:00 2001 From: bilal Date: Fri, 30 Jan 2026 18:46:39 +0300 Subject: [PATCH 6/8] write scanBinarySiganlSequences function --- .../js-projects/lab-signal-pattern-detector/script.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js index ab63d33e5..e6e4d36d4 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js @@ -49,3 +49,13 @@ function findMissingFrames(sequence, pattern) { return missingFrames } + +function scanBinarySignalSequences(sequences, motifLength, pattern) { + return sequences.map((sequence) => { + return { + motifPositions: findMotif(sequence, motifLength), + mirrorsBroken: detectMirror(sequence), + missingFrames: findMissingFrames(sequence, pattern), + } + }) +} From 8cb1d0891e755314881ad7c7e9cfd5f18e419972 Mon Sep 17 00:00:00 2001 From: bilal Date: Thu, 12 Mar 2026 03:22:24 +0300 Subject: [PATCH 7/8] change the user stories to fit the new lab --- .../user-stories.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md b/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md index e3c58e6e9..2a922e349 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/user-stories.md @@ -1,19 +1,9 @@ -In this lab, you will create a function that accepts binary signal sequences and find the motif, mirror patterns, and missing frame in each sequence. - -**Binary Signal Sequence**: An array of 0s and 1s - -**Motif**: A repeating pattern. For example, this sequence `[1, 0, 0, 1, 1, 0, 1, 0, 0, 1]` has this pattern `1, 0, 0, 1` repeated twice. So this pattern is considered a motif. - -**Mirror Pattern**: A pattern that consists of a porition and the symetrical mirror version of that portion immediately after it. For example, this sequence `[0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]` has a mirror pattern, `[1, 0, 0, 1, 1, 0, 0, 1]`. The first portion, `1, 0, 0, 1`, when reversed from right to left gives the second portion, `1, 0, 0, 1`, which is the same as the first portion. - -**Missing Frame**: A frame in the sequence that is neither 0 or 1. +In this lab, you will create a proofreading tool, a tool that checks text for repeated phrases and palindrome breaks. **Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. **User Stories**: -1. You should accept an array of signal sequences (each sequence is an array of 0s and 1s). -2. You should implement `findMotif(sequence, motifLength)` using nested loops with early exit flags. -3. You should implement `detectMirror(sequence)` that compares mirrored indices and reports mismatches. -4. You should implement `findMissingFrames(sequence)` that logs gaps in expected binary patterns. -5. You should aggregate results into `{ motifPositions, mirrorsBroken, missingFrames }` for each sequence. +1. You should implement `findRepeatedPhrases(words, phraseLength)` - given an array of words and a phrase length, find the starting indices of any repeated word sequences. Use nested loops with early exit `break` flags. +2. You should implement `findPalindromeBreaks(words)` — given an array of words, find the indices where the word-level palindrome is broken. +3. You should implement `analyseTexts(texts, phraseLength)` — run both checks on each text in an array and return an array of result objects. From 9e56fb247d822cf99c7101ba4a06da881e3504f7 Mon Sep 17 00:00:00 2001 From: bilal Date: Mon, 16 Mar 2026 08:08:51 +0300 Subject: [PATCH 8/8] update prototype to fit the new lab --- .../lab-signal-pattern-detector/script.js | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js index e6e4d36d4..9d5050906 100644 --- a/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js +++ b/fullstack-cert/js-projects/lab-signal-pattern-detector/script.js @@ -1,61 +1,49 @@ -function findMotif(sequence, motifLength) { - const motifPositions = [] +function findRepeatedPhrases(words, phraseLength) { + const repeatedWordsIndecies = [] - for (let i = 0; i <= sequence.length - motifLength; i++) { - for (let j = i + 1; j <= sequence.length - motifLength; j++) { + for (let i = 0; i <= words.length - phraseLength; i++) { + for (let j = i + 1; j <= words.length - phraseLength; j++) { let match = true - for (let k = 0; k < motifLength; k++) { - if (sequence[i + k] !== sequence[j + k]) { + for (let k = 0; k < phraseLength; k++) { + if (words[i + k] !== words[j + k]) { match = false break } } if (match) { - motifPositions.push(i) + repeatedWordsIndecies.push(i) break } } } - return motifPositions + return repeatedWordsIndecies } -function detectMirror(sequence) { - const mirrorsBroken = [] +function findPalindromeBreaks(words) { + const palindromesBroken = [] - for (let i = 0; i < Math.floor(sequence.length / 2); i++) { - const mirrorIndex = sequence.length - 1 - i + for (let i = 0; i < Math.floor(words.length / 2); i++) { + const palindromeIndex = words.length - 1 - i - if (sequence[i] !== sequence[mirrorIndex]) { - mirrorsBroken.push(i) + if (words[i] !== words[palindromeIndex]) { + palindromesBroken.push(i) } } - return mirrorsBroken + return palindromesBroken } -function findMissingFrames(sequence, pattern) { - const missingFrames = [] +function analyseTexts(texts, phraseLength) { + let results = [] + for (let i = 0; i < texts.length; i++) { + const repeatedPhrases = findRepeatedPhrases(texts[i], phraseLength) + const palindromeBreaks = findPalindromeBreaks(texts[i]) - for (let i = 0; i < sequence.length; i++) { - const expectedFrame = pattern[i % pattern.length] - - if (sequence[i] !== expectedFrame) { - missingFrames.push(i) - } + results.push({ repeatedPhrases, palindromeBreaks }) } - return missingFrames -} - -function scanBinarySignalSequences(sequences, motifLength, pattern) { - return sequences.map((sequence) => { - return { - motifPositions: findMotif(sequence, motifLength), - mirrorsBroken: detectMirror(sequence), - missingFrames: findMissingFrames(sequence, pattern), - } - }) + return results }