Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Day-01/go/artur/day01.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"os"
"strconv"
"strings"
)

func main() {
input, _ := os.ReadFile("Day-01/go/artur/input.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input, _ := os.ReadFile("Day-01/go/artur/input.txt")
input, _ := os.ReadFile("input01.txt")

Solutions should be straightforward to run, so it's best if input files are relative paths

lines := strings.Split(string(input), "\n")

countP1 := 0
countP2 := 0
dial := int64(50)
for _, line := range lines {
increase, _ := strconv.ParseInt(line[1:], 10, 64)

for ; increase != 0; increase-- {
if line[0] == 'R' {
dial = (dial + 1) % 100
} else {
dial = (dial - 1) % 100
}
if dial == 0 {
countP2++
}
}
if dial == 0 {
countP1++
}
}
println(countP1)
println(countP2)
}
28 changes: 28 additions & 0 deletions Day-02/go/artur/day02.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"os"
"strconv"
"strings"
)

func main() {
input, _ := os.ReadFile("Day-02/go/artur/input.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input, _ := os.ReadFile("Day-02/go/artur/input.txt")
input, _ := os.ReadFile("input02.txt")

doubleIds := strings.Split(string(input), ",")
result := 0
for _, idRange := range doubleIds {
idSplit := strings.Split(idRange, "-")
id1, _ := strconv.Atoi(idSplit[0])
id2, _ := strconv.Atoi(idSplit[1])
for ; id1 <= id2; id1++ {
id1String := strconv.Itoa(id1)
if len(id1String)%2 == 1 {
continue
}
if id1String[:len(id1String)/2] == id1String[len(id1String)/2:] {
result += id1
}
}
}
println(result)
}