old shit
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
**/input*.txt
|
**/input*.txt
|
||||||
.DS_Store
|
**/test*.txt
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
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
|
||||||
|
)
|
||||||
@@ -1,32 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
filePath := os.Args[1]
|
lines := parse()
|
||||||
readFile, err := os.Open(filePath)
|
|
||||||
|
|
||||||
if err != nil {
|
for _, line := range lines {
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
fileScanner := bufio.NewScanner(readFile)
|
|
||||||
fileScanner.Split(bufio.ScanLines)
|
|
||||||
var fileLines []string
|
|
||||||
|
|
||||||
for fileScanner.Scan() {
|
|
||||||
fileLines = append(fileLines, fileScanner.Text())
|
|
||||||
}
|
|
||||||
|
|
||||||
readFile.Close()
|
|
||||||
|
|
||||||
for _, line := range fileLines {
|
|
||||||
fmt.Println(line)
|
fmt.Println(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(fileLines)
|
}
|
||||||
|
|
||||||
|
func parse() []string {
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, _ := os.ReadFile(filePath)
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
return chunks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source "$(dirname "$0")/../.env"
|
source "$(dirname "$0")/../.env"
|
||||||
|
|
||||||
day=$(date +%d)
|
day=$(date +%-d)
|
||||||
|
|
||||||
echo "Getting input for day $day"
|
echo "Getting input for day $day"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user