Edit: Since I seem to be making a hash of this, here's my original method, which seems to pass all tests, however it still makes use of chunk_while
, which, according to the comments, is a no-go for some reason:
def almost_increasing_sequence?(array)
chunks = array.chunk_while(&:<).to_a
return true if chunks.size < 2
return false if chunks.size > 2
head, tail = chunks
return true if head.size == 1 || tail.size == 1
head[-2] < tail.first || head.last < tail[1]
end