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 = $(`.
I
have thought of something but I found it wierd that you do
steps when you have already the answer.������
That is indeed true, personally I would decide based on how
often the method is called and how large the input is. Because
this cumulative change makes it much easier to debug any
issues... and usually I prefer debuggability over performance
(unless it is an actual bottleneck).
Peter