Post History
JavaScript (Node.js), 70 56 bytes f=([a,...b],c=f)=>1/a?Math.max(f(b,c),[a]>c&&1+f(b,a)):0 Try it online!
Answer
#4: Post edited
# [JavaScript (Node.js)], <del>70</del> <del>69</del> 66 bytes- <!-- language-all: lang-javascript -->
f=(a,b=0,c=f,d=a[b++])=>1/d?Math.max(f(a,b,c),[d]>c&&1+f(a,b,d)):0[Try it online!][TIO-ki3kzt4q]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-ki3kzt4q]: https://tio.run/##dcpLDoIwGEXhuQshNFyxBfFFiitwBU0HPy34CFIjxLj7WuLM4PR850YvGszz@hiXvbON962MCbXkMLKFlaTqJNFMVmJljycaL@md3nE7PTAMyurKRJFIvsUyduC@NK4fXNeknTuHVWnGysVvFLM1w3wXyJDPShFEYP1Ht8F2EBw59ijCtkE2jf4D "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], <del>70</del> 56 bytes
- <!-- language-all: lang-javascript -->
- f=([a,...b],c=f)=>1/a?Math.max(f(b,c),[a]>c&&1+f(b,a)):0
- [Try it online!][TIO-ki3l8gjd]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-ki3l8gjd]: https://tio.run/##dYpJDoIwFIb3HoT0xd9KQXAgxRN4AtLFo4JDkBohxtvXsjW4/IY7v3mwr9tzXPXu3HjfalExpJS1gdUt6VKt@Xji8Sof/BGtqGEJFZvSRpFaTsxEh9gX1vWD6xrZuUvYKkNULH6lmrUJ5r1CgnS2ZKEobP7UbWg7qBgp9sjCliOZRv8F "JavaScript (Node.js) – Try It Online"
#3: Post edited
# [JavaScript (Node.js)], <del>70</del> 69 bytes- <!-- language-all: lang-javascript -->
f=(a,b=0,c=f,d=a[b++],e=[d]>c)=>1/d?Math.max(f(a,b,c),f(a,b,d)*e+e):0[Try it online!][TIO-ki3gk7ea]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-ki3gk7ea]: https://tio.run/##dYpLDoIwGAb3noRfPpGC4IMUT@AJGhalDx9BaoQYb19L3BncTWbmJl9yUM/rY1z1ThvvLY8kWp5CcQvNpWjjuIHhQje1Il6ztT6e5HhJ7vId2emFInxB09LEhg6pr5TrB9eZpHPncImGqFr8SjZrM8x7hgz5bClCYdj8qdvQdmApcuxRhK1ENo3@Aw "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], <del>70</del> <del>69</del> 66 bytes
- <!-- language-all: lang-javascript -->
- f=(a,b=0,c=f,d=a[b++])=>1/d?Math.max(f(a,b,c),[d]>c&&1+f(a,b,d)):0
- [Try it online!][TIO-ki3kzt4q]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-ki3kzt4q]: https://tio.run/##dcpLDoIwGEXhuQshNFyxBfFFiitwBU0HPy34CFIjxLj7WuLM4PR850YvGszz@hiXvbON962MCbXkMLKFlaTqJNFMVmJljycaL@md3nE7PTAMyurKRJFIvsUyduC@NK4fXNeknTuHVWnGysVvFLM1w3wXyJDPShFEYP1Ht8F2EBw59ijCtkE2jf4D "JavaScript (Node.js) – Try It Online"
#2: Post edited
# [JavaScript (Node.js)], 70 bytes- <!-- language-all: lang-javascript -->
f=(a,b=0,c=-1/0,d=a[b++],e=d>c)=>1/d?Math.max(f(a,b,c),f(a,b,d)*e+e):0[Try it online!][TIO-ki3g3v74]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-ki3g3v74]: https://tio.run/##dYpLDoIwAAX3noTaB7RF8EOKJ/AEhEVpi58gNUKMt68l7gzuJjNzUy816uf1McWDM9b7TkYKrWTQMuYpg5GqbiltYKWpNJEVT83xpKZLclfvqJtnaIIvGLK21JID86V2w@h6m/TuHK66IaRc/Uq@aAWWPYdAtljyUDg2f@o2tB04Q4Y98rAVEPPoPw "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], <del>70</del> 69 bytes
- <!-- language-all: lang-javascript -->
- f=(a,b=0,c=f,d=a[b++],e=[d]>c)=>1/d?Math.max(f(a,b,c),f(a,b,d)*e+e):0
- [Try it online!][TIO-ki3gk7ea]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-ki3gk7ea]: https://tio.run/##dYpLDoIwGAb3noRfPpGC4IMUT@AJGhalDx9BaoQYb19L3BncTWbmJl9yUM/rY1z1ThvvLY8kWp5CcQvNpWjjuIHhQje1Il6ztT6e5HhJ7vId2emFInxB09LEhg6pr5TrB9eZpHPncImGqFr8SjZrM8x7hgz5bClCYdj8qdvQdmApcuxRhK1ENo3@Aw "JavaScript (Node.js) – Try It Online"
#1: Initial revision
# [JavaScript (Node.js)], 70 bytes <!-- language-all: lang-javascript --> f=(a,b=0,c=-1/0,d=a[b++],e=d>c)=>1/d?Math.max(f(a,b,c),f(a,b,d)*e+e):0 [Try it online!][TIO-ki3g3v74] [JavaScript (Node.js)]: https://nodejs.org [TIO-ki3g3v74]: https://tio.run/##dYpLDoIwAAX3noTaB7RF8EOKJ/AEhEVpi58gNUKMt68l7gzuJjNzUy816uf1McWDM9b7TkYKrWTQMuYpg5GqbiltYKWpNJEVT83xpKZLclfvqJtnaIIvGLK21JID86V2w@h6m/TuHK66IaRc/Uq@aAWWPYdAtljyUDg2f@o2tB04Q4Y98rAVEPPoPw "JavaScript (Node.js) – Try It Online"