Hi,
I am posting this as a little challenge so maybe i can get better ideas.
The code is to be written so that it can detect a series of redundant code execution where the code is quite simple.
First we have:
if conditionA then
DoA()
elsif conditionB then
DoB()
end if
(note because of the 'if' and 'elsif' it is possible to NOT execute either one);
As you can see there are simply two conditions A and B, and the point is to detect say 5 recurrences of sequential execution of A then B or B then A. If either get executed two times in a row (like A A or B B) or neither gets executed then the count is to be reset so that it only detects A B or B A recurrences. In fact, if it just detects AB recurrences that would probably be good enough.
So it would have to detect AB AB AB AB AB or BA BA BA BA BA
and if at any time we get neither of those (AB or BA) or we get AA or BB we reset the count and start all over again.
The code would of course have to at least include a count say 'cnt' and it would increment on AB or BA and reset on AA or BB or Neither AB or BA.
A last requirement is that the count of recurrences has to be able to be increased or decreased, like say from 3 to 100 for example rather than just 5. This would be done manually not in the program (like "if cnt=10 then Reset()").
This is to be used in a larger program.
See what you can come up with
I am posting this as a little challenge so maybe i can get better ideas.
The code is to be written so that it can detect a series of redundant code execution where the code is quite simple.
First we have:
if conditionA then
DoA()
elsif conditionB then
DoB()
end if
(note because of the 'if' and 'elsif' it is possible to NOT execute either one);
As you can see there are simply two conditions A and B, and the point is to detect say 5 recurrences of sequential execution of A then B or B then A. If either get executed two times in a row (like A A or B B) or neither gets executed then the count is to be reset so that it only detects A B or B A recurrences. In fact, if it just detects AB recurrences that would probably be good enough.
So it would have to detect AB AB AB AB AB or BA BA BA BA BA
and if at any time we get neither of those (AB or BA) or we get AA or BB we reset the count and start all over again.
The code would of course have to at least include a count say 'cnt' and it would increment on AB or BA and reset on AA or BB or Neither AB or BA.
A last requirement is that the count of recurrences has to be able to be increased or decreased, like say from 3 to 100 for example rather than just 5. This would be done manually not in the program (like "if cnt=10 then Reset()").
This is to be used in a larger program.
See what you can come up with