Back to Problem Solutions forum
Dear Brothers and Sisters, please kindly advice : To check the previous occurence of element in ArrayList I use the ".contains(value)" method and upon receiving boolean == true I am performing on a second step the ".indexOf(value)" method.
Looks like seems logic, isn't it ?
But ... Unfortunately all the receiving index values which I was submited then were exactly less on 3 than the Correct ones ( difference = 3 between the Correct values and mines )
What I did not concerned correctly in both those methods implementation ?
Thank you in advance ( fragments of code are below ):
// previously 1st value from list added
int tempval = val;
tempval = get_new_rand( tempval); // the second random value calculated here
boolean ifcontains = randval.contains( tempval ) ;
while ( ifcontains != true )
{ randval.add( tempval );
tempval = get_new_rand( tempval); // calculate next value based on tempval
ifcontains = randval.contains( tempval ) ;
}
int idx = randval.indexOf( tempval ) ;
return idx+1 ; // to compensate the ZERO offset
Hi Rodion, Pls ignore this thread: I solved it correctly now ! ( I've found that used the wrong method. after correction all starts working like the swiss clock ;-) ) Thank you for the challenge and have a nice weekend !
Hi Eli!
Pls ignore this thread: I solved it correctly now !
Ha-ha! I confess that this time I intentionally decided to allow some delay - suspecting that you probably will figure this out (which I believe is always more useful), so I'm happy I guessed right :)
BTW, congratulations on reaching the next rank / color!