Concerning Day1, part2 of Advent Of Code 2018, here's my quick take (Coded in a workspace with Squeak)... | file total numbers index frequencies duplicate | duplicate := false. frequencies := Set new: 150000. frequencies add: 0. numbers := OrderedCollection new: 1000. total := 0. file := StandardFileStream readOnlyFileNamed: 'day.1.input'. [file atEnd] whileFalse: [numbers add: (Integer readFrom: file nextLine)]. 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 ----------------- Benoît St-Jean Yahoo! Messenger: bstjean Twitter: @BenLeChialeux Pinterest: benoitstjean Instagram: Chef_Benito IRC: lamneth Blogue: endormitoire.wordpress.com "A standpoint is an intellectual horizon of radius zero". (A. Einstein) On Monday, December 3, 2018, 2:01:08 a.m. EST, phil@highoctane.be <phil@highoctane.be> wrote: Also, given the time that some people solve the puzzle, doing it too nice is actually not the best use of time in AoC. Now, I'll try to solve quick and this will for sure lead to interesting things in Pharo.
From Reddit, people solve it quick then make it nice. Phil On Mon, Dec 3, 2018, 03:45 Richard O'Keefe <raoknz@gmail.com wrote:
The key question is "what do you mean by improve"?I'd start by asking "what are you doing that you will still have to do inpart 2, and what won't you do?" So looking at part 2, you will want toconvert the lines to integers, and input := Array streamContents: [:lines |  'input.txt' asFileReference readStreamDo: [:in |   [in atEnd] whileFalse: [lines nextPut: in nextLine asInteger]]].gives you a chunk of code you can use in both parts. So you mightwant to have Day1 changesFrom: aFileName  ^Array streamContents: [:changes |   aFileName asFileReference readStreamDo: [:in |    [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]] partOne: aFileName  ^(self changesFrom: aFileName) sum partTwo: aFileName  ...The file name should not be wired in because you want some test files.