old shit
This commit is contained in:
3
2023/01/go.mod
Normal file
3
2023/01/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module main
|
||||
|
||||
go 1.21.4
|
||||
44
2023/01/main.go
Normal file
44
2023/01/main.go
Normal 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
5
2023/go.work
Normal file
@@ -0,0 +1,5 @@
|
||||
go 1.21.4
|
||||
|
||||
use (
|
||||
./01
|
||||
)
|
||||
Reference in New Issue
Block a user