hello

I have this code

hasReachedBasement: aFloor
    "comment stating purpose of message"

    ^ aFloor = -1

initialize
    "comment stating purpose of message"

    super initialize.
    position := 1.
    floor := 0

moveFloorDown: aFloor
    "comment stating purpose of message"

    ^ floor := aFloor - 1

moveFloorUp: aFloor
    "comment stating purpose of message"

    ^ floor := aFloor + 1

reachedBasement: input2
    input2
        withIndexDo: [ :element :index |
            element = $(
                ifTrue: [ self moveFloorUp: floor ]
                ifFalse: [ self moveFloorDown: floor ].
            (self hasReachedBasement: floor)
                ifTrue: [ position := index ] ].
    position ifNotNil: [ ^ position ]

This works very fine with test input given by the challenge
but as soon as I do it with this : https://gist.github.com/RoelofWobben/3be69976a6dd3531f01558b0ac563556

I see as answer : 6111 where I expect to see 1797

Anyone who can see what I did wrong ?

Roelof


Reply via email to