We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 132bd12 commit 7a9a7b1Copy full SHA for 7a9a7b1
2022.playground/Pages/Day01.xcplaygroundpage/Contents.swift
@@ -22,6 +22,13 @@ func partOne() -> Int {
22
return highestCalorie[0].caloriesSum
23
}
24
25
+func partTwo() -> Int {
26
+ let input = load(file: "input01", ofType: .txt)!
27
+ var elves = getElves(from: input)
28
+ var highestCalorie = elves.sorted { $0.caloriesSum > $1.caloriesSum }
29
+ return highestCalorie[0].caloriesSum + highestCalorie[1].caloriesSum + highestCalorie[2].caloriesSum
30
+}
31
+
32
func getElves(from input: String) -> [Elf] {
33
let elvesCalories = input.split(separator: "\n\n")
34
var elves: [Elf] = []
@@ -33,5 +40,6 @@ func getElves(from input: String) -> [Elf] {
40
41
35
42
print(partOne())
43
+print(partTwo())
36
44
37
45
//: [Next](@next)
0 commit comments