Created
November 14, 2013 00:44
-
-
Save straypacket/7459270 to your computer and use it in GitHub Desktop.
Codility - Lesson 3 Genomic-range-query 66/100
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
def solution(s, p, q) | |
v = {"A" => 1, "C" => 2, "G" => 3, "T" => 4} | |
min_nuc = [] | |
if s!= nil and p != nil and q != nil | |
if p.length > 0 and q.length > 0 | |
if p.length == q.length | |
p.length.times.each do |i| | |
max = 5 | |
s[p[i]..q[i]].each_char do |c| | |
max = v[c] if v[c] < max | |
end | |
min_nuc << max | |
end | |
end | |
end | |
end | |
return min_nuc | |
end | |
def solution(s, p, q) | |
v = {"A" => 1, "C" => 2, "G" => 3, "T" => 4} | |
min_nuc = [] | |
if s!= nil and p != nil and q != nil | |
if p.length > 0 and q.length > 0 | |
if p.length == q.length | |
p.length.times.each do |i| | |
min_nuc << s[p[i]..q[i]].split('').map {|c| v[c]}.min | |
end | |
end | |
end | |
end | |
return min_nuc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment