found it.

I use the old reading code from part1.
but on part2 you did add the input to the numbers collection

so numbers was keeping empty

sorry for the noise

Roelof



Op 3-12-2018 om 16:13 schreef Benoit St-Jean via Pharo-users:
| file total numbers index frequencies duplicate |

duplicate := false.
frequencies := Set new: 150000.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := StandardFileStream readOnlyFileNamed: 'C:\Recv\day.1.input'.
[file atEnd] whileFalse: [numbers add: (file nextLine asInteger)].
file close.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
                        total := total + numbers at: index.
                        (frequencies includes: total)
                            ifTrue: [duplicate := true]
                            ifFalse: [frequencies add: total]].

total


Reply via email to