diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index be1a55ecd92..64f97f7e77a 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -3473,6 +3473,12 @@ "In this lab, you will design a sum all numbers algorithm. This algorithm takes an array of two numbers and returns the sum of those two numbers plus the sum of all the numbers between them." ] }, + "lab-dna-pair-generator": { + "title": "Implement a DNA Pair Generator", + "intro": [ + "In this lab you will implement a DNA base pairing algorithm that converts a single DNA strand into complementary base pairs." + ] + }, "lab-html-entitiy-converter": { "title": "Implement an HTML Entity Converter", "intro": [ diff --git a/client/src/pages/learn/full-stack-developer/lab-dna-pair-generator/index.md b/client/src/pages/learn/full-stack-developer/lab-dna-pair-generator/index.md new file mode 100644 index 00000000000..d9495f28fcc --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/lab-dna-pair-generator/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Implement a DNA Pair Generator +block: lab-dna-pair-generator +superBlock: full-stack-developer +--- + +## Introduction to the Implement a DNA Pair Generator + +In this lab you will implement a DNA base pairing algorithm that converts a single DNA strand into complementary base pairs. diff --git a/curriculum/challenges/english/blocks/lab-dna-pair-generator/afd15382cdfb22c9efe8b7de.md b/curriculum/challenges/english/blocks/lab-dna-pair-generator/afd15382cdfb22c9efe8b7de.md new file mode 100644 index 00000000000..a43c98c339b --- /dev/null +++ b/curriculum/challenges/english/blocks/lab-dna-pair-generator/afd15382cdfb22c9efe8b7de.md @@ -0,0 +1,100 @@ +--- +id: afd15382cdfb22c9efe8b7de +title: Implement a DNA Pair Generator +challengeType: 26 +dashedName: implement-a-dna-pair-generator +--- + +# --description-- + +Pairs of DNA strands consist of nucleobase pairs. Base pairs are represented by the characters AT and CG, which form building blocks of the DNA double helix. + +In this lab, you will write a function to match the missing base pairs for the provided DNA strand. For each character in the provided string, find the base pair character. + +For example, for the input `GCG`, return `[["G", "C"], ["C", "G"], ["G", "C"]]` + +The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array. + +**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. You should have a `pairElement` function that takes a string as an argument. +1. The `pairElement` function should return a 2d array. +1. When given `A`, the function should pair it with `T`. +1. When given `T`, the function should pair it with `A`. +1. When given `C`, the function should pair it with `G`. +1. When given `G`, the function should pair it with `C`. +1. Each pair should be returned as an array with the original character first and its complement second. + +# --hints-- + +You should create a function named `pairElement`. + +```js +assert.isFunction(pairElement); +``` + +`pairElement` should take a single argument. + +```js +assert.lengthOf(pairElement, 1); +``` + +`pairElement("ATCGA")` should return `[["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]`. + +```js +assert.deepEqual(pairElement('ATCGA'), [ + ['A', 'T'], + ['T', 'A'], + ['C', 'G'], + ['G', 'C'], + ['A', 'T'] +]); +``` + +`pairElement("TTGAG")` should return `[["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]`. + +```js +assert.deepEqual(pairElement('TTGAG'), [ + ['T', 'A'], + ['T', 'A'], + ['G', 'C'], + ['A', 'T'], + ['G', 'C'] +]); +``` + +`pairElement("CTCTA")` should return `[["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]`. + +```js +assert.deepEqual(pairElement('CTCTA'), [ + ['C', 'G'], + ['T', 'A'], + ['C', 'G'], + ['T', 'A'], + ['A', 'T'] +]); +``` + +# --seed-- + +## --seed-contents-- + +```js + +``` + +# --solutions-- + +```js +var lookup = Object.create(null); +lookup.A = 'T'; +lookup.T = 'A'; +lookup.C = 'G'; +lookup.G = 'C'; + +function pairElement(str) { + return str.split('').map(function(p) {return [p, lookup[p]];}); +} +``` diff --git a/curriculum/structure/blocks/lab-dna-pair-generator.json b/curriculum/structure/blocks/lab-dna-pair-generator.json new file mode 100644 index 00000000000..8d89602134f --- /dev/null +++ b/curriculum/structure/blocks/lab-dna-pair-generator.json @@ -0,0 +1,15 @@ +{ + "name": "Implement a DNA Pair Generator", + "isUpcomingChange": false, + "dashedName": "lab-dna-pair-generator", + "helpCategory": "JavaScript", + "blockLayout": "link", + "blockType": "lab", + "challengeOrder": [ + { + "id": "afd15382cdfb22c9efe8b7de", + "title": "Implement a DNA Pair Generator" + } + ], + "usesMultifileEditor": true +} diff --git a/curriculum/structure/superblocks/full-stack-developer.json b/curriculum/structure/superblocks/full-stack-developer.json index a20100509a5..67ab338540e 100644 --- a/curriculum/structure/superblocks/full-stack-developer.json +++ b/curriculum/structure/superblocks/full-stack-developer.json @@ -388,6 +388,7 @@ "lecture-working-with-the-arguments-object-and-rest-parameters", "lab-password-generator", "lab-sum-all-numbers-algorithm", + "lab-dna-pair-generator", "lab-html-entitiy-converter", "lab-optional-arguments-sum-function", "review-javascript-fundamentals",