Skip to content

Commit de703ec

Browse files
committed
2022/03 comment
1 parent f2341ef commit de703ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

2022/Day03/Solution.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ namespace AdventOfCode.Y2022.Day03;
88
class Solution : Solver {
99

1010
public object PartOne(string input) =>
11+
// A line can be divided to two 'compartments' of equal length. We need
12+
// to find the common item (letter) in them, and convert it to a number
13+
// called 'priority'. Do this for each line and sum the priorities.
14+
// We use 'chunk' to split a line in half.
1115
input.Split("\n")
1216
.Select(line => line.Chunk(line.Length/2)) // 🥩
1317
.Select(GetCommonItemPriority)
1418
.Sum();
1519

1620
public object PartTwo(string input) =>
21+
// Here we need to find the common item in three consecutive lines,
22+
// convert it to priority as before, and sum it up along the whole
23+
// input.
24+
// This is again conveniently done using the chunk function.
1725
input.Split("\n")
1826
.Chunk(3)
1927
.Select(GetCommonItemPriority)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy