2024 day 4 - part 1 & part 2
This commit is contained in:
parent
71c18eaeba
commit
0627e2b811
140
2024/day-04/input.txt
Normal file
140
2024/day-04/input.txt
Normal file
@ -0,0 +1,140 @@
|
||||
MMAMMMSAXAXXAXMASMMASAMXMAMMAMXXXXXSMSXMMMXMXXSXASAMXMAMMXSAMXXXXMSSMXMASMMMSMSSSSSXMXSASMSMMMMMXAMXAXMMSMMAXSSSXSXMXAMXMXSXSMSSXSAMXXXMXMXM
|
||||
ASASAAMXMXMMMXAXAXSSMXSASASMSSXMMSMMSAMXMMSSMASAMXMXMMMSMMMASMXSAMAMMXMAMAAXAAXAAAAMMSAMXAAXAASMSSSMSSSMAAMXMAAXMMASMSSMMXMAXAAAASAMXSXMASAM
|
||||
MSASMSSMMAAASMXSMMXAAMSAMASAAAMAAAASXMAXSAAAMSMMXAMAMAMAXAXAXAASMMAMMXMASXMSMSMMMMMAXMASMXMSXXMAAXAAAAASXMMAAMSMMSAMXAAXXAMXMMMSMSASAAASASXS
|
||||
MMAMAXMASMSXXMASXMMMMMMMMMMMMXAXSMXMAMXXMMSSMMAMMAXXSASXSXMAMMMMXSMSMXXAMAASAMMXMASXXXXSXMMXMSMMMSMMMSMMSASMMXAAXAASMSMMSXSAXAAMXSAMMSMMASAA
|
||||
MMMMXMSXMXXAAMAMASXMAAAXAMXAASMMMXMSXMSXMXAAASAMSSXAXAXAAMXMXSASMMAAAMMMSSMMAMSXSAXMAMMMXAAAAAAAXXAAXAAXSXMASMSSMSXMAAXMAMMASMXXAMXMXAXMXMMM
|
||||
ASAXMAMAMASXXMASAMASXSSSMSSMXSAASAMXAMMAMMSSMMXMAMXMMSMMMSSMAXXMAMSMSAAXMXASXMSASMSMAMAAMSSSSSMMMSSMSMXMXXXMXAAMAXMSMSXMASXAMXAMSMMXSMXSAXMX
|
||||
XMASXSSXMASMSSXMASXMMMAAAAAXXSMMMMMSAMSSMAMMAMMMASXXAAAXXAAMXMMSSMAMXXSSMSXMXXMAMAAMSXXXMAMMA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|
||||
SSMMSXMASMXSXSSSSSXSMMASMSXSSMMMMMSMSXXMMAMXMAMAMSSSMSSMXMASMSMMXMXMMAXSXSXMMXMSAMXXASXMMMMMMMMSMMSSXXMASXMMAMASMMSSMMSSXMSAMSAAXMAMXXMASXMM
|
BIN
2024/day-04/main
Executable file
BIN
2024/day-04/main
Executable file
Binary file not shown.
@ -6,8 +6,69 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type direction struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
|
||||
var (
|
||||
undef direction = direction{0, 0}
|
||||
north direction = direction{-1, 0}
|
||||
north_east direction = direction{-1, 1}
|
||||
east direction = direction{0, 1}
|
||||
south_east direction = direction{1, 1}
|
||||
south direction = direction{1, 0}
|
||||
south_west direction = direction{1, -1}
|
||||
west direction = direction{0, -1}
|
||||
north_west direction = direction{-1, -1}
|
||||
)
|
||||
|
||||
func checkX_MAS(field [][]string, x int, y int) bool {
|
||||
ne := getChar(field, x+north_east.X, y+north_east.Y)
|
||||
se := getChar(field, x+south_east.X, y+south_east.Y)
|
||||
sw := getChar(field, x+south_west.X, y+south_west.Y)
|
||||
nw := getChar(field, x+north_west.X, y+north_west.Y)
|
||||
|
||||
// All allowed options
|
||||
// M.S
|
||||
// .A.
|
||||
// M.S
|
||||
//
|
||||
// S.S
|
||||
// .A.
|
||||
// M.M
|
||||
//
|
||||
// S.M
|
||||
// .A.
|
||||
// S.M
|
||||
//
|
||||
// M.M
|
||||
// .A.
|
||||
// S.S
|
||||
|
||||
pattern := fmt.Sprintf("%s%s%s%s", ne, se, sw, nw)
|
||||
if pattern == "SSMM" || pattern == "SMMS" || pattern == "MMSS" || pattern == "MSSM" {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func getChar(field [][]string, x, y int) string {
|
||||
bound_x := len(field)
|
||||
if x == -1 || x >= bound_x {
|
||||
return ""
|
||||
}
|
||||
bound_y := len(field[x])
|
||||
if y == -1 || y >= bound_y {
|
||||
return ""
|
||||
}
|
||||
|
||||
return field[x][y]
|
||||
}
|
||||
|
||||
func main() {
|
||||
content, err := os.ReadFile("./input_test.txt")
|
||||
content, err := os.ReadFile("./input.txt")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open file: %s\n", err)
|
||||
}
|
||||
@ -17,6 +78,8 @@ func main() {
|
||||
x_axis := 0
|
||||
y_axis := 0
|
||||
|
||||
result2 := 0
|
||||
|
||||
for _, b := range content {
|
||||
char := string(b)
|
||||
if char == "\n" {
|
||||
@ -36,15 +99,31 @@ func main() {
|
||||
|
||||
var found [][]pos
|
||||
|
||||
for x, _ := range field {
|
||||
for y, _ := range field[x] {
|
||||
// empty array for the found chars
|
||||
seq := []pos{}
|
||||
checkXMAS(field, x, y, seq, &found)
|
||||
for x := 0; x < len(field); x++ {
|
||||
for y := 0; y < len(field[x]); y++ {
|
||||
if field[x][y] == "X" {
|
||||
seq := []pos{}
|
||||
seq = append(seq, pos{x, y})
|
||||
checkXMAS(field, x+north.X, y+north.Y, seq, &found, north)
|
||||
checkXMAS(field, x+north_east.X, y+north_east.Y, seq, &found, north_east)
|
||||
checkXMAS(field, x+east.X, y+east.Y, seq, &found, east)
|
||||
checkXMAS(field, x+south_east.X, y+south_east.Y, seq, &found, south_east)
|
||||
checkXMAS(field, x+south.X, y+south.Y, seq, &found, south)
|
||||
checkXMAS(field, x+south_west.X, y+south_west.Y, seq, &found, south_west)
|
||||
checkXMAS(field, x+west.X, y+west.Y, seq, &found, west)
|
||||
checkXMAS(field, x+north_west.X, y+north_west.Y, seq, &found, north_west)
|
||||
|
||||
}
|
||||
if field[x][y] == "A" {
|
||||
if checkX_MAS(field, x, y) {
|
||||
result2++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("found: ", len(found))
|
||||
fmt.Println("result part 1: ", len(found))
|
||||
fmt.Println("result part 2: ", result2)
|
||||
}
|
||||
|
||||
type pos struct {
|
||||
@ -60,20 +139,13 @@ func seqToString(field [][]string, seq []pos) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func checkXMAS(field [][]string, x int, y int, current_seq []pos, found *[][]pos) {
|
||||
bound_x := len(field)
|
||||
if x == -1 || x >= bound_x {
|
||||
func checkXMAS(field [][]string, x int, y int, current_seq []pos, found *[][]pos, dir direction) {
|
||||
char := getChar(field, x, y)
|
||||
if char == "" {
|
||||
return
|
||||
}
|
||||
bound_y := len(field[x])
|
||||
if y == -1 || y >= bound_y {
|
||||
return
|
||||
}
|
||||
|
||||
char := field[x][y]
|
||||
|
||||
seq_str := seqToString(field, current_seq)
|
||||
// fmt.Printf("x: %d y: %d seq: '%s' curr_char: '%s'\n", x, y, seq_str, char)
|
||||
|
||||
if (seq_str == "" && char == "X") ||
|
||||
(seq_str == "X" && char == "M") ||
|
||||
@ -90,19 +162,18 @@ func checkXMAS(field [][]string, x int, y int, current_seq []pos, found *[][]pos
|
||||
*found = append(*found, current_seq)
|
||||
}
|
||||
|
||||
// y
|
||||
// x 0 1 2 3
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3
|
||||
// nort = -1, 0
|
||||
// north_east = -1, 1
|
||||
// east = 0, 1
|
||||
// south_east = 1, 1
|
||||
// south = 1, 0
|
||||
// south_west = 1, -1
|
||||
// west = 0, -1
|
||||
|
||||
checkXMAS(field, x+1, y, current_seq, found)
|
||||
checkXMAS(field, x-1, y, current_seq, found)
|
||||
checkXMAS(field, x, y+1, current_seq, found)
|
||||
checkXMAS(field, x, y-1, current_seq, found)
|
||||
// [0, 0] [0, 1] [0, 2] [0, 3]
|
||||
// [1, 0] [1, 1] [1, 2] [1, 3]
|
||||
// [2, 0] [2, 1] [2, 2] [2, 3]
|
||||
// [3, 0] [3, 1] [3, 2] [3, 3]
|
||||
|
||||
checkXMAS(field, x+1, y+1, current_seq, found)
|
||||
checkXMAS(field, x+1, y-1, current_seq, found)
|
||||
checkXMAS(field, x-1, y+1, current_seq, found)
|
||||
checkXMAS(field, x-1, y-1, current_seq, found)
|
||||
checkXMAS(field, x+dir.X, y+dir.Y, current_seq, found, dir)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user