Skip to content

Instantly share code, notes, and snippets.

@straypacket
Created November 14, 2013 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save straypacket/7459270 to your computer and use it in GitHub Desktop.
Save straypacket/7459270 to your computer and use it in GitHub Desktop.
Codility - Lesson 3 Genomic-range-query 66/100
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