Skip to content

Commit

Permalink
fix all source files to support both windows crlf and unix lf in inpu…
Browse files Browse the repository at this point in the history
…t file
  • Loading branch information
aleche28 committed Dec 7, 2024
1 parent 8d86e0c commit c52ad9b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion solutions/alessio/day01/day01.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func part2(lines []string) {
func main() {
data, err := os.ReadFile("./input01.txt")
check(err)
lines := strings.Split(strings.Trim(string(data), "\r\n"), "\r\n")
dataStr := strings.ReplaceAll(string(data), "\r\n", "\n")
lines := strings.Split(strings.Trim(dataStr, "\n"), "\n")

part1(lines)
part2(lines)
Expand Down
4 changes: 2 additions & 2 deletions solutions/alessio/day02/day02.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func part2(lines []string) {
func main() {
data, err := os.ReadFile("./input02.txt")
check(err)

lines := strings.Split(strings.Trim(string(data), "\r\n"), "\r\n")
dataStr := strings.ReplaceAll(string(data), "\r\n", "\n")
lines := strings.Split(strings.Trim(dataStr, "\n"), "\n")

part1(lines)
part2(lines)
Expand Down
4 changes: 2 additions & 2 deletions solutions/alessio/day03/day03.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func part2(lines []string) {
func main() {
data, err := os.ReadFile("./input03.txt")
check(err)

lines := strings.Split(strings.Trim(string(data), "\r\n"), "\r\n")
dataStr := strings.ReplaceAll(string(data), "\r\n", "\n")
lines := strings.Split(strings.Trim(dataStr, "\n"), "\n")

part1(lines)
part2(lines)
Expand Down
4 changes: 2 additions & 2 deletions solutions/alessio/day04/day04.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func part2(lines []string) {
func main() {
data, err := os.ReadFile("./input04.txt")
check(err)

lines := strings.Split(strings.Trim(string(data), "\r\n"), "\r\n")
dataStr := strings.ReplaceAll(string(data), "\r\n", "\n")
lines := strings.Split(strings.Trim(dataStr, "\n"), "\n")

part1(lines)
part2(lines)
Expand Down
4 changes: 2 additions & 2 deletions solutions/alessio/day05/day05.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func part2(lines []string) {
func main() {
data, err := os.ReadFile("./input05.txt")
check(err)

lines := strings.Split(strings.Trim(string(data), "\r\n"), "\r\n")
dataStr := strings.ReplaceAll(string(data), "\r\n", "\n")
lines := strings.Split(strings.Trim(dataStr, "\n"), "\n")

part1(lines)
part2(lines)
Expand Down

0 comments on commit c52ad9b

Please sign in to comment.