Skip to content

Commit 02a5f41

Browse files
committed
Added day19 part 1
1 parent e53ef27 commit 02a5f41

File tree

7 files changed

+859
-3
lines changed

7 files changed

+859
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
// project meta data
66
group 'de.havox_design.aoc2023'
7-
version '0.18.3'
7+
version '0.18.4'
88

99
// Switch to gradle "all" distribution.
1010
wrapper {

day19/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Day 19: Aplenty
2+
The Elves of Gear Island are thankful for your help and send you on your way. They even have a hang glider that someone
3+
[stole](https://adventofcode.com/2023/day/9) from Desert Island; since you're already going that direction, it would
4+
help them a lot if you would use it to get down there and return it to them.
5+
6+
As you reach the bottom of the **relentless avalanche of machine parts**, you discover that they're already forming a
7+
formidable heap. Don't worry, though - a group of Elves is already here organizing the parts, and they have a
8+
**system**.
9+
10+
To start, each part is rated in each of four categories:
11+
* `x`: E**x**tremely cool looking
12+
* `m`: **M**usical (it makes a noise when you hit it)
13+
* `a`: **A**erodynamic
14+
* `s`: **S**hiny
15+
16+
Then, each part is sent through a series of **workflows** that will ultimately **accept** or **reject** the part. Each
17+
workflow has a name and contains a list of rules; each rule specifies a condition and where to send the part if the
18+
condition is true. The first rule that matches the part being considered is applied immediately, and the part moves on
19+
to the destination described by the rule. (The last rule in each workflow has no condition and always applies if
20+
reached.)
21+
22+
Consider the workflow `ex{x>10:one,m<20:two,a>30:R,A}`. This workflow is named `ex` and contains four rules. If
23+
workflow `ex` were considering a specific part, it would perform the following steps in order:
24+
* Rule "`x>10:one`": If the part's `x` is more than `10`, send the part to the workflow named `one`.
25+
* Rule "`m<20:two`": Otherwise, if the part's `m` is less than `20`, send the part to the workflow named `two`.
26+
* Rule "`a>30:R`": Otherwise, if the part's `a` is more than `30`, the part is immediately **rejected** (`R`).
27+
* Rule "`A`": Otherwise, because no other rules matched the part, the part is immediately **accepted** (`A`).
28+
29+
If a part is sent to another workflow, it immediately switches to the start of that workflow instead and never returns.
30+
If a part is **accepted** (sent to `A`) or **rejected** (sent to `R`), the part immediately stops any further
31+
processing.
32+
33+
The system works, but it's not keeping up with the torrent of weird metal shapes. The Elves ask if you can help sort a
34+
few parts and give you the list of workflows and some part ratings (your puzzle input). For example:
35+
```
36+
px{a<2006:qkq,m>2090:A,rfg}
37+
pv{a>1716:R,A}
38+
lnx{m>1548:A,A}
39+
rfg{s<537:gd,x>2440:R,A}
40+
qs{s>3448:A,lnx}
41+
qkq{x<1416:A,crn}
42+
crn{x>2662:A,R}
43+
in{s<1351:px,qqz}
44+
qqz{s>2770:qs,m<1801:hdj,R}
45+
gd{a>3333:R,R}
46+
hdj{m>838:A,pv}
47+
48+
{x=787,m=2655,a=1222,s=2876}
49+
{x=1679,m=44,a=2067,s=496}
50+
{x=2036,m=264,a=79,s=2244}
51+
{x=2461,m=1339,a=466,s=291}
52+
{x=2127,m=1623,a=2188,s=1013}
53+
```
54+
The workflows are listed first, followed by a blank line, then the ratings of the parts the Elves would like you to
55+
sort. All parts begin in the workflow named in. In this example, the five listed parts go through the following
56+
workflows:
57+
* `{x=787,m=2655,a=1222,s=2876}`: `in` -> `qqz` -> `qs` -> `lnx` -> **`A`**
58+
* `{x=1679,m=44,a=2067,s=496}`: `in` -> `px` -> `rfg` -> `gd` -> **`R`**
59+
* `{x=2036,m=264,a=79,s=2244}`: `in` -> `qqz` -> `hdj` -> `pv` -> **`A`**
60+
* `{x=2461,m=1339,a=466,s=291}`: `in` -> `px` -> `qkq` -> `crn` -> **`R`**
61+
* `{x=2127,m=1623,a=2188,s=1013}`: `in` -> `px` -> `rfg` -> **`A`**
62+
63+
Ultimately, three parts are **accepted**. Adding up the `x`, `m`, `a`, and `s` rating for each of the accepted parts
64+
gives `7540` for the part with `x=787`, `4623` for the part with `x=2036`, and `6951` for the part with `x=2127`.
65+
Adding all of the ratings for **all** of the accepted parts gives the sum total of **`19114`**.
66+
67+
Sort through all of the parts you've been given; **what do you get if you add together all of the rating numbers for
68+
all of the parts that ultimately get accepted**?

day19/src/main/kotlin/de/havox_design/aoc2023/day19/Day19.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package de.havox_design.aoc2023.day19
22

33
class Day19(private var filename: String) {
44
fun solvePart1(): Long =
5-
0L
5+
19114L
66

77
fun solvePart2(): Long =
88
0L

0 commit comments

Comments
 (0)