I'm programming in Eiffel for a school Lab, and one of the tasks is to find a bug in a given algorithm. The algorithm returns the first repeated character.
The algorithm works as follows:
word: STRING
first_repeated_character: CHARACTER
local
i: INTEGER
ch: CHARACTER
stop: BOOLEAN
do
from
i := 1
Result := '%U'
until
i > word.count or stop
loop
ch := word[i]
if ch = word[i + 1] then
Result := ch
stop := true
end
i := i + 1
end
end
I spent the last couple of hours trying to find the bug in this, but it always passes all tests.
Any help would be much appreciated. Thanks.