diff options
author | bd <bdunahu@operationnull.com> | 2024-06-10 16:31:02 -0600 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2024-06-10 16:31:02 -0600 |
commit | 9e149cb6e6f1bf002fb1abc2b79c77afc3d1d36c (patch) | |
tree | 65621c8bb1fd326574f0a62191185d477c60b642 /trebuchet/README.org | |
parent | 58ee9f48c4c90352bccdb1cc88d7b9ef923f9216 (diff) |
AoC 2023.1 p1+2
Diffstat (limited to 'trebuchet/README.org')
-rw-r--r-- | trebuchet/README.org | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/trebuchet/README.org b/trebuchet/README.org new file mode 100644 index 0000000..da1b6e5 --- /dev/null +++ b/trebuchet/README.org @@ -0,0 +1,38 @@ +See: https://adventofcode.com/2023/day/1 +** Part 1 +*** Purpose +Given a list of lines of characters, each with a minimum of one integers: + +#+begin_example +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet +#+end_example + +Reduce each line to the first and last integer, then add all lines together. If a line contains a single integer, count that integer twice. + +*** Method + +The solution to this is obvious---filter the non-numeric characters out of the each line, index the first and last characters, and then make the summation. + +** Part 2 +*** Purpose +The next part now asserts that some spelt out numbers are unaccounted for. For example: + +#+begin_example +two1nine +#+end_example + +Should return the digit "29". We must calculate the new sum, with this rule in place. + +*** Method +With this addition, it makes the most sense to perform some cleaning on each input string---substitute spelt numbers for actual numbers, then send it down the usual processing. + +Lots of code was required to make this work---also noteworthy, is that this useful piece of information is not in the instructions: + +#+begin_example +twone -> 21 +#+end_example + +because a letter is shared. |