Skip to content

Commit

Permalink
Day 1 and Day 2 solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
yashpatil1998 committed Dec 2, 2022
0 parents commit a1e8db3
Show file tree
Hide file tree
Showing 10 changed files with 9,927 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea

.DS_Store
23 changes: 23 additions & 0 deletions day1/day1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package day1

import (
"sort"
"strconv"
"strings"
)

func Day1Logic() (int, int) {
var response []int
listOfItems := strings.Split(input1, "\n\n")
for _, items := range listOfItems {
caloriesList := strings.Split(items, "\n")
sumOfCalories := 0
for _, cal := range caloriesList {
calInt, _ := strconv.Atoi(cal)
sumOfCalories += calInt
}
response = append(response, sumOfCalories)
}
sort.Ints(response)
return response[len(response)-1], response[len(response)-1] + response[len(response)-2] + response[len(response)-3]
}
Loading

0 comments on commit a1e8db3

Please sign in to comment.