Created
September 11, 2018 22:54
-
-
Save arrbxr/b11d7379d1123db298f0830006fee30b to your computer and use it in GitHub Desktop.
integer sequence created by arrbxr - https://repl.it/@arrbxr/integer-sequence
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
function sequence(seq) { | |
var bad = 0 | |
for(var i=1;i<seq.length;i++) { | |
if(seq[i]<=seq[i-1]) { | |
bad++ | |
if(bad>1) { | |
return false | |
} | |
if(seq[i]<=seq[i-2]&&seq[i+1]<=seq[i-1]) { | |
return false | |
} | |
} | |
} | |
return true | |
} | |
sequence([1,1,2,8,3,2,4,5]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment