Skip to content

Commit

Permalink
21/02/09 reduce : Strip の実装5
Browse files Browse the repository at this point in the history
  • Loading branch information
righ1113 committed Feb 8, 2021
1 parent 4adb63c commit 53a7342
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions program/lib/r_strip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,33 @@ def strip_sub2(g_conf, verts, ring, done, term)
term
end

def in_interval(_grav, _done)
0
def in_interval(grav, done)
d = grav[0 + 1]
first = 1
while first < d && !done[grav[first + 1]] do first += 1 end
return (done[grav[d + 1]] ? 1 : 0) if first == d
last = first

while last < d && done[grav[1 + last + 1]] do last += 1 end
length = last - first + 1
return length if last == d

if first > 1
((last + 2)..d).each do |j|
return 0 if done[grav[j + 1]]
end
return length
end
worried = false
((last + 2)..d).each do |j|
if done[grav[j + 1]]
length += 1
worried = true
elsif worried
return 0
end
end
length
end
end
end

0 comments on commit 53a7342

Please sign in to comment.