Created
October 10, 2016 06:18
-
-
Save yevgnenll/667630df7dd9d3dadf35ce6101cf6933 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.min = function() { | |
return Math.min.apply(null, this); | |
}; | |
function solution(nucleo, start, end) { | |
var result = []; | |
if(nucleo.length === 1){ | |
count = Math.min(start.length, end.length); | |
for(var i=0; i<count; i++){ | |
result.push(get_nucleo_number(nucleo[0])); | |
return result; | |
} | |
} | |
var check_nucleo = ''; | |
for(var i=0; i<start.length; i++){ | |
check_nucleo = nucleo.slice(start[i], end[i]+1); | |
result.push(get_minimal(check_nucleo)); | |
} | |
return result; | |
} | |
function get_nucleo_number(string){ | |
data = {'A':1, 'C':2, 'G':3, 'T':4}; | |
return data[string]; | |
} | |
function get_minimal(divided_nucleo){ | |
if(divided_nucleo.length === 1) | |
return get_nucleo_number(divided_nucleo[0]); | |
var min = 10; | |
for(var i=0; i<divided_nucleo.length; i++){ | |
convert = get_nucleo_number(divided_nucleo[i]); | |
if (min > convert){ | |
min = convert; | |
} | |
} | |
return min; | |
} | |
p = [2, 5, 0]; | |
q = [4, 5, 6]; | |
s = 'CAGCCTA'; | |
s1 = 'C' | |
console.log(solution(s, p, q)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bigO 신경안씀