Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c97ea16

Browse filesBrowse files
committed
Final configuration, code, and solution to Advent of Code 2024 Day 3, Part 1.
1 parent 5ffbd7d commit c97ea16
Copy full SHA for c97ea16

File tree

8 files changed

+102
-0
lines changed
Filter options

8 files changed

+102
-0
lines changed

‎2024/day03_1/.idea/inspectionProfiles/Project_Default.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/inspectionProfiles/Project_Default.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/.idea/kotlinc.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/kotlinc.xml
+10Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/.idea/libraries/KotlinJavaRuntime.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/libraries/KotlinJavaRuntime.xml
+17Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/.idea/misc.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/misc.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/.idea/modules.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/modules.xml
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/.idea/vcs.xml

Copy file name to clipboardExpand all lines: 2024/day03_1/.idea/vcs.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎2024/day03_1/day03_1.iml

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
7+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
9+
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
10+
</content>
11+
<orderEntry type="inheritedJdk" />
12+
<orderEntry type="sourceFolder" forTests="false" />
13+
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
14+
</component>
15+
</module>

‎2024/day03_1/src/Main.kt

Copy file name to clipboard
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.io.File
2+
3+
// important note: RegEx that handles the problem: mul\(\d{1,3},\d{1,3}\)
4+
fun main(args: Array<String>) {
5+
println("AOC 2024, Day 3, Part 1 starting!!!!")
6+
7+
val theOperations = MulOperations()
8+
val theRegex = "mul\\(\\d{1,3},\\d{1,3}\\)".toRegex()
9+
File(args[0]).forEachLine {
10+
val theMatches = theRegex.findAll(it)
11+
for(match in theMatches) {
12+
println("tlarsen,L11: match = ${match.value}")
13+
theOperations.dataList.add(match.value)
14+
}
15+
}
16+
17+
println("The answer: ${theOperations.results()}")
18+
19+
println("AOC 2024, Day 3, Part 1 completed!!!")
20+
}
21+
22+
class MulOperations {
23+
val dataList = ArrayList<String>()
24+
25+
fun results():Long {
26+
var theResult = 0L
27+
val regex = "(\\d{1,3})".toRegex()
28+
for(d in dataList) {
29+
val theMatches = regex.findAll(d)
30+
theResult += (theMatches.first().value.toLong() * theMatches.last().value.toLong())
31+
}
32+
return theResult
33+
}
34+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.