* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.8 KiB
1.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
afd15382cdfb22c9efe8b7de | DNA 配对 | 5 | 16009 | dna-pairing |
--description--
给出的 DNA 链上缺少配对元素。请基于每个字符,获取与其配对的元素,并将结果作为二维数组返回。
DNA 的碱基对 有两种形式:一种是 A 与 T,一种是 C 与 G。请为参数中给出的每个字符配对相应的碱基。
注意,参数中给出的字符应作为每个子数组中的第一个元素返回。
例如,传入 GCG 时,应返回 "G", "C"], ["C", "G"], ["G", "C"。
参数中的字符及与其配对的碱基应存在于一个数组中,代表碱基对。再将每个配对完成的碱基对数组按顺序放到一个数组中,作为最终的返回结果。
--hints--
pairElement("ATCGA")
应返回 [["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]
。
assert.deepEqual(pairElement('ATCGA'), [
['A', 'T'],
['T', 'A'],
['C', 'G'],
['G', 'C'],
['A', 'T']
]);
pairElement("TTGAG")
应返回 [["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]
。
assert.deepEqual(pairElement('TTGAG'), [
['T', 'A'],
['T', 'A'],
['G', 'C'],
['A', 'T'],
['G', 'C']
]);
pairElement("CTCTA")
应返回 [["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]
。
assert.deepEqual(pairElement('CTCTA'), [
['C', 'G'],
['T', 'A'],
['C', 'G'],
['T', 'A'],
['A', 'T']
]);
--seed--
--seed-contents--
function pairElement(str) {
return str;
}
pairElement("GCG");
--solutions--
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]];});
}