2 replaced http://stackoverflow.com/ with https://stackoverflow.com/
source | link

So as to establish a baseline:

Ruby (38)

Assuming a is an array:

r,i=1,0;a.map{|x|i+=1;x==a[i-2]?r:r=i}

(This is based on falsetru's answerfalsetru's answer on the original SO thread and isn't my original work. I know there's a Ruby solution that's 22 characters, but I'd like to see someone come up with one shorter than that in Ruby.)

So as to establish a baseline:

Ruby (38)

Assuming a is an array:

r,i=1,0;a.map{|x|i+=1;x==a[i-2]?r:r=i}

(This is based on falsetru's answer on the original SO thread and isn't my original work. I know there's a Ruby solution that's 22 characters, but I'd like to see someone come up with one shorter than that in Ruby.)

So as to establish a baseline:

Ruby (38)

Assuming a is an array:

r,i=1,0;a.map{|x|i+=1;x==a[i-2]?r:r=i}

(This is based on falsetru's answer on the original SO thread and isn't my original work. I know there's a Ruby solution that's 22 characters, but I'd like to see someone come up with one shorter than that in Ruby.)

1
source | link

So as to establish a baseline:

Ruby (38)

Assuming a is an array:

r,i=1,0;a.map{|x|i+=1;x==a[i-2]?r:r=i}

(This is based on falsetru's answer on the original SO thread and isn't my original work. I know there's a Ruby solution that's 22 characters, but I'd like to see someone come up with one shorter than that in Ruby.)