File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 14
14
0 to: integerValues size prec Do: [| :i. a |
15
15
a: integerValues at: i.
16
16
i succ to: integerValues size Do: [| :j. b |
17
- "'i: ' print. i _StringPrint. ' j: ' print. j _StringPrint. '' printLine."
18
- b: integerValues at: j.
17
+ b: integerValues at: j.
19
18
((a + b) = 2020) ifTrue: [
20
19
^ a * b.
21
20
].
22
21
].
23
22
].
24
23
).
25
24
26
- part2 = 'TODO part 2'.
25
+ part2 = (| values. integerValues |
26
+ values: input splitOn: ' '.
27
+ integerValues: values copy.
28
+ values do: [| :value. :i | integerValues at: i Put: value toInteger ].
29
+
30
+ 0 to: integerValues size prec Do: [| :i. a |
31
+ a: integerValues at: i.
32
+ i succ to: integerValues size Do: [| :j. b |
33
+ b: integerValues at: j.
34
+ j succ to: integerValues size Do: [| :k. c |
35
+ c: integerValues at: k.
36
+ ((a + b + c) = 2020) ifTrue: [
37
+ ^ a * b * c.
38
+ ].
39
+ ].
40
+ ].
41
+ ].
42
+ ).
27
43
28
44
main = (
29
45
'Part 1: ' print. part1 _StringPrint. '' printLine.
30
- part2 printLine.
46
+ 'Part 2: ' print. part2 _StringPrint. '' printLine.
31
47
).
32
48
|) main.
You can’t perform that action at this time.
0 commit comments