diff --git a/2025/day/1/part1/go.mod b/2025/day/1/part1/go.mod deleted file mode 100644 index 33b8ed2..0000000 --- a/2025/day/1/part1/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module part1 - -go 1.23.4 diff --git a/2025/day/1/part1/part1.go b/2025/day/1/part1/part1.go deleted file mode 100644 index 747e085..0000000 --- a/2025/day/1/part1/part1.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "os" - "strconv" -) - -func main() { - file, _ := os.Open("input.txt") - defer file.Close() - - scanner := bufio.NewScanner(file) - current := 50 - counter := 0 - for scanner.Scan() { - line := scanner.Text() - direction := line[0] - multiplier := 1 - if direction == 'L' { - multiplier = -1 - } - number, _ := strconv.Atoi(line[1:]) - current += number * multiplier - current = ((current % 100) + 100) % 100 - if current == 0 { - counter++ - } - // fmt.Printf("%s %c %d %d %d %d\n", line, direction, number, multiplier, current, counter) - } - fmt.Printf("%d\n", counter) -} diff --git a/2025/day/1/part2/go.mod b/2025/day/1/part2/go.mod deleted file mode 100644 index e4c7d61..0000000 --- a/2025/day/1/part2/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module part2 - -go 1.23.4 diff --git a/2025/day/1/part2/part2.go b/2025/day1/day1.go similarity index 52% rename from 2025/day/1/part2/part2.go rename to 2025/day1/day1.go index 2341328..cf907e8 100644 --- a/2025/day/1/part2/part2.go +++ b/2025/day1/day1.go @@ -8,7 +8,32 @@ import ( "strconv" ) -func main() { +func part1() { + file, _ := os.Open("input.txt") + defer file.Close() + + scanner := bufio.NewScanner(file) + current := 50 + counter := 0 + for scanner.Scan() { + line := scanner.Text() + direction := line[0] + multiplier := 1 + if direction == 'L' { + multiplier = -1 + } + number, _ := strconv.Atoi(line[1:]) + current += number * multiplier + current = ((current % 100) + 100) % 100 + if current == 0 { + counter++ + } + // fmt.Printf("%s %c %d %d %d %d\n", line, direction, number, multiplier, current, counter) + } + fmt.Printf("%d\n", counter) +} + +func part2() { file, _ := os.Open("input.txt") defer file.Close() @@ -36,3 +61,8 @@ func main() { } fmt.Printf("%d\n", counter) } + +func main() { + part1() + part2() +} diff --git a/2025/day1/go.mod b/2025/day1/go.mod new file mode 100644 index 0000000..b538081 --- /dev/null +++ b/2025/day1/go.mod @@ -0,0 +1,3 @@ +module day1 + +go 1.23.4