add 2024/day3
This commit is contained in:
parent
02b95a7e65
commit
a7c0239f66
4 changed files with 90 additions and 0 deletions
14
helper/convert.go
Normal file
14
helper/convert.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ToInt(s string) int {
|
||||
i, _ := strconv.Atoi(s)
|
||||
return i
|
||||
}
|
||||
|
||||
func ToString(i int) string {
|
||||
return strconv.Itoa(i)
|
||||
}
|
|
@ -51,3 +51,21 @@ func ReadLinesToIntSlices() (lines [][]int) {
|
|||
|
||||
return lines
|
||||
}
|
||||
|
||||
func ReadLinesToStringSlices() (lines []string) {
|
||||
scanner := getLines()
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func ReadLinesToString() (line string) {
|
||||
scanner := getLines()
|
||||
for scanner.Scan() {
|
||||
line += scanner.Text()
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue