Python 3.8 (pre-release), 162 bytes
# 164 bytes (used in TIO link)
f=lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
# 162 bytes (actual submission)
lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
"Port" of Luis felipe De jesus Munoz's answer. Try its test cases Try its test cases. t=[7] can be replaced with any other one-digit number for no extra cost. Explanation / readable version in TIO header and my painful debugging helper below
_queue = [];function print(...args) {_queue.push([args[0], args.slice(1)])}function release(l) {args_ = [];isStart = true;for (let i of _queue) {args_.push((isStart?l:'')+(i[0][0]=='.'?i[0].slice(1):'\n'+i[0]));for (let j of i[1]) {args_.push(j)}isStart=false}console.log(...args_)}
f=(x,t=1)=>x.map((a,i)=>{
print('inner',t,a,i)
p = [ t+=(i&&a!=x[i-1]) , -~i*t ]
ret = p[0] && p[1];
print('.returning',t,a,i,p[0],p[1],ret)
return ret});(l=>{f(Array.from(l));release(l)})('DDDD')
Python 3.8 (pre-release), 131 bytes, non-reusable
lambda x,t=[1]:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))]
Omits t.__setitem__(0,1). Test cases
Python 3.8 (pre-release), 162 bytes
# 164 bytes (used in TIO link)
f=lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
# 162 bytes (actual submission)
lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
"Port" of Luis felipe De jesus Munoz's answer. Try its test cases. t=[7] can be replaced with any other one-digit number for no extra cost. Explanation / readable version in TIO header and my painful debugging helper below
_queue = [];function print(...args) {_queue.push([args[0], args.slice(1)])}function release(l) {args_ = [];isStart = true;for (let i of _queue) {args_.push((isStart?l:'')+(i[0][0]=='.'?i[0].slice(1):'\n'+i[0]));for (let j of i[1]) {args_.push(j)}isStart=false}console.log(...args_)}
f=(x,t=1)=>x.map((a,i)=>{
print('inner',t,a,i)
p = [ t+=(i&&a!=x[i-1]) , -~i*t ]
ret = p[0] && p[1];
print('.returning',t,a,i,p[0],p[1],ret)
return ret});(l=>{f(Array.from(l));release(l)})('DDDD')
Python 3.8 (pre-release), 131 bytes, non-reusable
lambda x,t=[1]:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))]
Omits t.__setitem__(0,1). Test cases
Python 3.8 (pre-release), 162 bytes
lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
"Port" of Luis felipe De jesus Munoz's answer. Try its test cases. t=[7] can be replaced with any other one-digit number for no extra cost. Explanation / readable version in TIO header and my painful debugging helper below
_queue = [];function print(...args) {_queue.push([args[0], args.slice(1)])}function release(l) {args_ = [];isStart = true;for (let i of _queue) {args_.push((isStart?l:'')+(i[0][0]=='.'?i[0].slice(1):'\n'+i[0]));for (let j of i[1]) {args_.push(j)}isStart=false}console.log(...args_)}
f=(x,t=1)=>x.map((a,i)=>{
print('inner',t,a,i)
p = [ t+=(i&&a!=x[i-1]) , -~i*t ]
ret = p[0] && p[1];
print('.returning',t,a,i,p[0],p[1],ret)
return ret});(l=>{f(Array.from(l));release(l)})('DDDD')
Python 3.8 (pre-release), 131 bytes, non-reusable
lambda x,t=[1]:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))]
Omits t.__setitem__(0,1). Test cases
Python 3.8 (pre-release), 162 bytes
# 164 bytes (used in TIO link)
f=lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
# 162 bytes (actual submission)
lambda x,t=[7]:(lambda m:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))])(t.__setitem__(0,1))
"Port" of Luis felipe De jesus Munoz's answer. Try its test cases. t=[7] can be replaced with any other one-digit number for no extra cost. Explanation / readable version in TIO header and my painful debugging helper below
_queue = [];function print(...args) {_queue.push([args[0], args.slice(1)])}function release(l) {args_ = [];isStart = true;for (let i of _queue) {args_.push((isStart?l:'')+(i[0][0]=='.'?i[0].slice(1):'\n'+i[0]));for (let j of i[1]) {args_.push(j)}isStart=false}console.log(...args_)}
f=(x,t=1)=>x.map((a,i)=>{
print('inner',t,a,i)
p = [ t+=(i&&a!=x[i-1]) , -~i*t ]
ret = p[0] && p[1];
print('.returning',t,a,i,p[0],p[1],ret)
return ret});(l=>{f(Array.from(l));release(l)})('DDDD')
Python 3.8 (pre-release), 131 bytes, non-reusable
lambda x,t=[1]:[*map(lambda i,a:(lambda m:t)(t.__setitem__(0,t[0]+(i and a!=(x[i-1]if i else 0))))and-~i*t[0],*zip(*enumerate(x)))]
Omits t.__setitem__(0,1). Test cases