Skip to content

Commit d67c87a

Browse files
2024 day 3 part 1
1 parent c3d08f8 commit d67c87a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

2024-php/03.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$input = trim(file_get_contents('03.txt'));
4+
5+
$matches = [];
6+
preg_match_all('/mul\((\d{1,3}),(\d{1,3})\)/', $input, $matches);
7+
8+
$pt1 = 0;
9+
for ($i = 0; $i < count($matches[0]); $i++) {
10+
$pt1 += $matches[1][$i] * $matches[2][$i];
11+
}
12+
13+
echo "Part 1: " , $pt1, PHP_EOL;

0 commit comments

Comments
 (0)