Hi Peter, On Fri, 9 Nov 2018 at 19:00, Alistair Grant <akgrant0710@gmail.com> wrote:
Hi Peter,
On Fri, 9 Nov 2018 at 18:51, Peter Uhnak <i.uhnak@gmail.com> wrote:
but how do I find now the answer do I have to do something like puzzle1 stepChanges detectIndex ?
How do you mean? It would be the same
santaFloorOnBasement "calculates which step take Santa to the basement"
stepChanges := input collect: [ :c | floor := floor + (c = '(' ifTrue: [ 1 ] ifFalse: [ -1 ]). floor ].
stepChanges detectIndex: [ :each | each = -1 ] ifNone: [ 'invalid input yo' ].
then I see this error message : Improper store to indexable object.
Because earlier you were comparing strings and not characters, I assumed your input was an array of strings like #('(' '(' '('). but you can fix that by changing `input collect:` -> `input asArray collect:` and `c = '('` -> `c = $(`.
Using '(' instead of $( is indeed an error, but it isn't the cause of the Improper store error.
I was too quick to respond here, I didn't look at the #asArray. Sorry! But still suggest Roelof looks at the debugger...
Roelof, I really suggest you trigger this error again, start the debugger and then take a look in the call stack (I'm assuming you're familiar with at least one other programming language, so should be able to figure out the debugger).
Cheers, Alistair