Re: [Pharo-users] can I improve this
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
participants (1)
-
Roelof Wobben