--- Begin Message ---
Hello,

My solution to day2 part1 is right this :

processData: instructions
    | opcode index firstNumber secondNumber placeToPut firstNumberIndex secondNumberIndex |
    index := 1.
    opcode := instructions at: index.
    [ opcode ~= 99 ]
        whileTrue: [ firstNumberIndex := instructions at: index + 1.
            secondNumberIndex := instructions at: index + 2.
            firstNumber := instructions at: firstNumberIndex + 1.
            secondNumber := instructions at: secondNumberIndex + 1.
            placeToPut := (instructions at: index + 3) + 1.
            opcode == 1
                ifTrue: [ instructions at: placeToPut put: firstNumber + secondNumber ].
            opcode == 2
                ifTrue: [ instructions at: placeToPut put: firstNumber * secondNumber ].
            index := index + 4.
            opcode := instructions at: index ].
    ^ instructions at: 1

so its ugly code

is there a way  I can this more the smalltalk way by using streams or something else. if so, is there someone who can tell me or can let me see how to make this cleaner code

Roelof



--- End Message ---

Reply via email to