02-19-2010 04:23 PM
02-19-2010 04:31 PM - edited 02-19-2010 04:32 PM
Michelle1892773 wrote:
Not very good... I hope excellent solution 😉
How have you known if my solution is not "excelent" then? 😄
Okay, do an example. Maybe somebody will manage to help you 😉
02-19-2010 04:51 PM
Michelle1892773 wrote:
I have explain what I need... maybe it's better if I do example?
Yes. As I said, either explain how Giedrius' solution is not right for you, or do your own work and post back if you have problems with how that works.
02-19-2010 04:54 PM - edited 02-19-2010 04:58 PM
I write the steps of the cycle, X is the variable that cycle modify, N is the random number that the cycle generate:
X=50;
N=24;
i=0:
N(0)=83;
N(0)<N; (START WITH +, IF START WITH - CHANGE + WITH - AFTER)
X(0)=50+1=51;
i=1:
N(1)=72;
N(1)<N(0); (YES, SAME OPERATION OF PREVIOUS STEP:+)
X(1)=51+1=52;
i=2:
N(2)=69;
N(2)<N(1); (YES, SAME OPERATION OF PREVIOUS STEP:+)
X(2)=52+1=53;
i=3:
N(3)=98;
N(3)<N(2); (NO, CHANGE OPERATION:-)
X(3)=53-1=52;
i=4:
N(4)=19;
N(4)<N(3); (YES, SAME OPERATION OF PREVIOUS STEP:-)
X(4)=52-1=51;
i=5:
N(5)=77;
N(5)<N(4); (NO, CHANGE OPERATION:+)
X(5)= 51+1=52;
CONDITION OF END: THERE ARE 2 CHANGE CONSECUTIVE.
02-19-2010 05:20 PM