1
0
Fork 0

add 2024/day2

This commit is contained in:
Sebastian Mark 2024-12-02 13:30:04 +01:00
parent 9cc8248821
commit e492d553aa
5 changed files with 1125 additions and 9 deletions

View file

@ -37,3 +37,17 @@ func ReadLinesTwoIntSlices() (list_a []int, list_b []int) {
return list_a, list_b
}
func ReadLinesToIntArrays() (lines [][]int) {
scanner := GetLines()
for scanner.Scan() {
string_line := strings.Fields(scanner.Text())
int_line := make([]int, len(string_line))
for i, val := range string_line {
int_line[i], _ = strconv.Atoi(val)
}
lines = append(lines, int_line)
}
return lines
}

9
2024/helper/math.go Normal file
View file

@ -0,0 +1,9 @@
package helper
func Abs(x int) int {
if x < 0 {
return -x
}
return x
}