Problem Explanation:
You will get a DNA strand sequence and you need to get the pair and return it as a 2D array of the base pairs. Keep in mind that the provided strand should be first always.
pairElement("ATCGA") should return [["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]].
pairElement("TTGAG") should return [["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]].
pairElement("CTCTA") should return [["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]].
function pairElement(str) { // Return each strand as an array of two elements, the original and the pair. var paired = []; // Function to check with strand to pair. var search = function(char) { switch (char) { case "A": paired.push(["A", "T"]); break; case "T": paired.push(["T", "A"]); break; case "C": paired.push(["C", "G"]); break; case "G": paired.push(["G", "C"]); break; } }; // Loops through the input and pair. for (var i = 0; i < str.length; i++) { search(str[i]); } return paired; } // test here pairElement("GCG");Intermediate Code Solution:
function pairElement(str) { //define a map object with all pair possibilities var map = {T:"A", A:"T", G:"C", C:"G"}; //split str into a char Array strArr = str.split(""); //replace each Array item with a 2d Array using map for (var i=0;ihttps://forum.freecodecamp.or...
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/84106.html
摘要:并看不懂我不會(huì)到處亂說。好吧我努力拆解一下這個(gè)正則是什么意思匹配字符串的開始重復(fù)一次或更多次匹配除了以外的任意字符原文 problem: You will create a program that will find the missing letter from a string and return it. If there is no missing letter, the p...
摘要:法一法二使用給定的參數(shù)對句子執(zhí)行一次查找和替換,然后返回新句子。法一法二把指定的字符串翻譯成。在每一個(gè)數(shù)組中將給定的字母作為第一個(gè)堿基返回。法一后項(xiàng)減去前項(xiàng)法二檢查一個(gè)值是否是基本布爾類型,并返回或。基本布爾類型即和。 Diff Two Arrays 比較兩個(gè)數(shù)組,然后返回一個(gè)新數(shù)組,該數(shù)組的元素為兩個(gè)給定數(shù)組中所有獨(dú)有的數(shù)組元素。換言之,返回兩個(gè)數(shù)組的差異。 function dif...
摘要:規(guī)則使用語言,讓函數(shù)獲取傳遞的參數(shù),并以相反的順序返回字符串。測試用例思路方法通過把字符串轉(zhuǎn)換成數(shù)組,并使用數(shù)組的反轉(zhuǎn)數(shù)組,然后使用重新拼接成字符串方法向后循環(huán)字符串或字符數(shù)組以生成新字符串 雖然都是很簡單的算法,每個(gè)都只需5分鐘左右,但寫起來總會(huì)遇到不同的小問題,希望大家能跟我一起每天進(jìn)步一點(diǎn)點(diǎn)。更多的小算法練習(xí),可以查看我的文章。 規(guī)則 Using the JavaScript l...
摘要:今天推出了一個(gè)名叫的開源工具,用深度神經(jīng)網(wǎng)絡(luò)來從測序數(shù)據(jù)中快速較精確識(shí)別堿基變異位點(diǎn)。今天,團(tuán)隊(duì),聯(lián)合同屬于旗下的生命科學(xué)兄弟公司,用了兩年多時(shí)間,研發(fā)出了一個(gè)名叫的開源工具,專門用深度神經(jīng)網(wǎng)絡(luò)來識(shí)別結(jié)果中測序數(shù)據(jù)里這些堿基變異位點(diǎn)。 Google今天推出了一個(gè)名叫DeepVariant的開源工具,用深度神經(jīng)網(wǎng)絡(luò)來從DNA測序數(shù)據(jù)中快速較精確識(shí)別堿基變異位點(diǎn)。學(xué)科研究的革命性進(jìn)展,特別是基因...
閱讀 2459·2021-10-08 10:17
閱讀 1834·2021-09-06 15:02
閱讀 2548·2019-08-29 17:30
閱讀 2672·2019-08-29 13:24
閱讀 1533·2019-08-29 11:12
閱讀 3345·2019-08-28 17:52
閱讀 675·2019-08-26 11:30
閱讀 3585·2019-08-26 11:01