Skip to content

Commit 06598fe

Browse files
committed
2024 Day 04 setup
1 parent 979d662 commit 06598fe

File tree

4 files changed

+220
-2
lines changed

4 files changed

+220
-2
lines changed

2024/day-03.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use adventofcode\Year2024\MultiplyInstructionParser;
66

77
/**
8-
* --- Day 3: Mull It Over ---
9-
*
108
* --- Day 3: Mull It Over ---
119
*
1210
* "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to

2024/day-04.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
//use adventofcode\Year2024\WordSearch;
6+
7+
/**
8+
* --- Day 4: Ceres Search ---
9+
*
10+
* "Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it.
11+
* After a brief flash, you recognize the interior of the Ceres monitoring station!
12+
*
13+
* As the search for the Chief continues, a small Elf who lives on the station tugs on your shirt; she'd like to know
14+
* if you could help her with her word search (your puzzle input). She only has to find one word: XMAS.
15+
*
16+
* This word search allows words to be horizontal, vertical, diagonal, written backwards, or even overlapping
17+
* other words. It's a little unusual, though, as you don't merely need to find one instance of XMAS - you need to
18+
* find all of them. Here are a few ways XMAS might appear, where irrelevant characters have been replaced with .:
19+
*
20+
* ..X...
21+
* .SAMX.
22+
* .A..A.
23+
* XMAS.S
24+
* .X....
25+
*
26+
* The actual word search will be full of letters instead. For example:
27+
*
28+
* MMMSXXMASM
29+
* MSAMXMSMSA
30+
* AMXSXMAAMM
31+
* MSAMASMSMX
32+
* XMASAMXAMM
33+
* XXAMMXXAMA
34+
* SMSMSASXSS
35+
* SAXAMASAAA
36+
* MAMMMXMMMM
37+
* MXMXAXMASX
38+
*
39+
* In this word search, XMAS occurs a total of 18 times; here's the same word search again, but where letters
40+
* not involved in any XMAS have been replaced with .:
41+
*
42+
* ....XXMAS.
43+
* .SAMXMS...
44+
* ...S..A...
45+
* ..A.A.MS.X
46+
* XMASAMX.MM
47+
* X.....XA.A
48+
* S.S.S.S.SS
49+
* .A.A.A.A.A
50+
* ..M.M.M.MM
51+
* .X.X.XMASX
52+
*
53+
* Take a look at the little Elf's word search. How many times does XMAS appear?
54+
*/
55+
56+
//$multiplyInstructionParser = new MultiplyInstructionParser();
57+
//
58+
//$lines = file(__DIR__ . '/inputs/day-04.input', FILE_IGNORE_NEW_LINES);
59+
//
60+
//$sum = $multiplyInstructionParser->findMultiplyInstructionSum($lines);
61+
//print('The sum of the multiplier instructions from the given input is ' . $sum . ".\n");
62+
63+
/**
64+
* --- Part Two ---
65+
*
66+
*
67+
*/
68+
69+
//$sum = $multiplyInstructionParser->findExtendedMultiplyInstructionSum($lines);
70+
//print('The sum of the extended multiplier instructions from the given input is ' . $sum . ".\n");

2024/inputs/day-04-sample.input

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MMMSXXMASM
2+
MSAMXMSMSA
3+
AMXSXMAAMM
4+
MSAMASMSMX
5+
XMASAMXAMM
6+
XXAMMXXAMA
7+
SMSMSASXSS
8+
SAXAMASAAA
9+
MAMMMXMMMM
10+
MXMXAXMASX

0 commit comments

Comments
 (0)