This commit is contained in:
2024-12-01 06:12:25 +02:00
parent c82ee691a1
commit b1816dcbf8
6 changed files with 66 additions and 20 deletions

3
2023/01/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module main
go 1.21.4

44
2023/01/main.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func main() {
lines := parse()
var first = 0
var last = 0
for _, line := range lines {
fmt.Println(line)
for i := 0; i < len(line); i++ {
//fmt.Println(int(line[i]))
x := strconv.Atoi(line[i])
if x {
first = x
break
}
}
for i := 0; i < len(line); i++ {
//fmt.Println(int(line[i]))
x, err := strconv.Atoi(line[i])
if err == nil {
last = x
break
}
}
}
}
func parse() []string {
filePath := os.Args[1]
data, _ := os.ReadFile(filePath)
chunks := strings.Split(string(data), "\n")
return chunks
}

5
2023/go.work Normal file
View File

@@ -0,0 +1,5 @@
go 1.21.4
use (
./01
)