add 2024/day2
This commit is contained in:
parent
9cc8248821
commit
e492d553aa
5 changed files with 1125 additions and 9 deletions
|
@ -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
9
2024/helper/math.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package helper
|
||||
|
||||
func Abs(x int) int {
|
||||
if x < 0 {
|
||||
return -x
|
||||
}
|
||||
|
||||
return x
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue