summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2022/day3/example6
-rw-r--r--2022/day3/input300
-rw-r--r--2022/day3/part1/Cargo.toml9
-rw-r--r--2022/day3/part1/src/main.rs24
-rw-r--r--2022/day3/part2/Cargo.toml9
-rw-r--r--2022/day3/part2/src/main.rs31
6 files changed, 379 insertions, 0 deletions
diff --git a/2022/day3/example b/2022/day3/example
new file mode 100644
index 0000000..f17e726
--- /dev/null
+++ b/2022/day3/example
@@ -0,0 +1,6 @@
1vJrwpWtwJgWrhcsFMMfFFhFp
2jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
3PmmdzqPrVvPwwTWBwg
4wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
5ttgJtRGJQctTZtZT
6CrZsJsPPZsGzwwsLwLmpwMDw
diff --git a/2022/day3/input b/2022/day3/input
new file mode 100644
index 0000000..e5e3940
--- /dev/null
+++ b/2022/day3/input
@@ -0,0 +1,300 @@
1DPstqDdrsqdDtqrFDJDDrmtsJHflSJCLgCphgHHgRHJCRRff
2BcBGcQzVBVZcvznTTTvZcGTpCRRRfRCggLflHlhhCZpZCj
3vGQnQvnzTzNTTbVnzGBqMqwqDLdPtMmbwqqLLM
4wLRFRqvFsFRjfrHddbdbjzdH
5lcsnSJPSSVVlGmGrHzbbrGNrdzbz
6mSmlnnPlmJmncVDSlSZSlmLBCvtwBvtLCqqswsDBCTWW
7pfqPrPgmmhvqdlsdWq
8nfjHLJfZcLbVtQWWtndhls
9CzJJFLzRzfDwrmggpC
10CWfllmlCDFlZZqMfmFBWmWLJVRLVwNNtRVGPpwtGpqbJ
11jHndndndcjhscnhHNtRbVtLbGpJbRRcb
12HSrvnQzQSMDlLzBCfg
13BQRVbgQQBJBbBtVBSSSRWMQbdNvvRPjZjCCdPLNZNNsNCCzd
14HwpFpnlGpGZWGvjzPd
15FTDmFrrwDpFMtmQVQQcWgc
16VhbPshVDPDFWhWsgDNMMbVtmBjwBffpwBntnmnqfnswt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DBWRhHBrhHDHhd
144vqZgnnqgLvqlPllpnjGDjmNjNLfftftLFD
145rfGsjsMNnFMMFddMsttDMgLHGlmJLCPPmHHGmHPlmm
146vZcbhQbrRbVZPJLwPTgCLlgb
147hchzSBqzQvphnWnrjFdWMqff
148WmfPWfVsfqszRDqPqgpvHhvdwddGMmGghM
149QtTrtTcSBjtQCctStrTrzhpwjGvGHhngwMHGHvMv
150TtTQlQFcSSJlcccBbltQQTTRsPZDsWzRFzWFzPNfsssLPs
151QpNNMrjcNMccGNdvLBBlBsBjnsnF
152tTSqbbbqCtWWCTWSVTmmCJPwVwnwvFPnsPVnnPfddlvf
153HmhJTZWqHqCJJJltqpNGRgzZDcQNrgzDGM
154HcLVRhhTRsLRRVjslTscqNQmVNQQgQttqNwNZtmw
155nJdBJJhfFPSCbJBJBMbzFbFgmNmtgmvgNgnntNwZQQNNmw
156bMbPzJbzCBPrJfdfbBbdCrGHlLTTpWjsGhGTTRTRlc
157sJCCpQJQCrfCfnSCrT
158vmqgNggzgmZqmPShqBhThfhDhjDhhB
159RZNzHRzZSQwHwHVVWc
160jtVtvVHgvjJbHjjQPMZdCcwlMdNbdFlNlc
161WppSBDzGfBzTBqQWwCFMlwZMwMcZ
162zBfnqpRGnSSqTfqpTpSnnHQsjJgQvPJshHtHVh
163qJMRMcPPVzVhmsDWfhWT
164BglQBNlgZtQBHLHHBnTjWSWmFmwDmWjSsnmF
165BdHvgHBvBtZbTpJRPCdcdpGrGJ
166pcGcWGWlvQZpzmDbgFmz
167HqqnddDdddjzTTggjZgFtT
168sHqRwrRsJswLHrMLLRJdqNVVrGffPGWcvSSWlDfGfc
169lttTbgRvqvtQRhjLzGjLVh
170JJfrHfrdffZJQmZhLLZVVwFj
171sBjCfSNNTTqnCnqD
172qMtWjSrHftGfjqrJGMqzVzFmBBrzQQwzgBVQVQ
173LDChPbThbTcTpCTcnPPQPQzVPvvzQBBWgVBQ
174ZLspppLpdZZttdHttqdWMf
175htJcJhpMQQWjhNWdJQ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Js
266BzssCmFNWWqWwqwPLH
267svzvvsmmFBmsggrGlGMVSMtMRRncSQScRRRl
268rmmqrQQwLbbGrrGr
269cNJzzzWtWmLCGGbLWWbv
270cVtMppchzMBVMcNJcMsRwqZFMlgmggmRgg
271mQsQBHFMrbddbRqH
272NzhcQNfNNtzvWwZdSrgbrprPrwLbgb
273zcJVhTtNNcvcfVZmBmQMGMMljTCmlB
274FlldqjSlCgfvPFfvFF
275rbnDtVBMbprTsbVVcTDTrpMcmNwgHPgghTmNfLwvfPNLwhdT
276drMppdnbbtQDBtbnsBbcrrtbSqSSRCjlQZWllllSRlWRGCCC
277nqdCsqbbwdsrHFVJHcwFTc
278jPPjtWjPWgRltRLsBRrNpHFDHVFWVVJNNHrD
279fgllPGQjBffLjtzSsqvbSSzGvnhS
280zsVBzMfHHnzlwwVlqcJJFT
281ZzRLvLDzQzTmlWlqWRWF
282GbQQvpGvSSpjdQjSQZpQZGLfrgBCsHzrdtCsnfCBHsBgdH
283zBLbLWzqqwLMnMZTnHlnsHTvFlFHNT
284fjhdcrjjdVdrGSmmdfccGclPvlvPTlGHTFgNvNgqFFvg
285pmmcrcRrjSVJchqVccjpRwZMDwCJQBbLDCCbwBWLzL
286TDMBgBgLlcjBfMfcVJVmGnnJjvPVCPVv
287zzptqHstJqFzzdJJZNvNpvNpnNvGnNZm
288dHszrWQhdzHQqdztwQBLSfglfDbfJlJTLg
289VTmvrldtGGwmlvmGDHlLnFDCCplFQHLH
290ssgjzSzzJCQSSFVVQF
291WsRWhgVqRtfvwcddhc
292bdlDwznhnNlffMcPTPfzzQ
293srCRGRrZCmVTBfBBfTQcZb
294brSrrGvRVvWmRsrHrWSbjNJwdDFhnNlwtlnSdnhN
295QQqqRfdQQSdjgPmZfBmmPgRhphphJtLmJhTJJhVbTtLhTb
296vvlNGzDDDcslcsGDlWHtCFVpcCbThFTtbJFtCh
297DrMGlzMVwNGWsWMHDMvlzlMfZdQdQPZfSZRfdrPBfqRZgj
298qVHfHNJCHVvvFFbfFlHHnCQQDhLnhhhPZrZnPZPn
299mSMszWRMQmhqrnZL
300GjtzjSSdRGSjsRtdRMttgGgsqqFNfFcGVvVVvlbHFFGFVFwb
diff --git a/2022/day3/part1/Cargo.toml b/2022/day3/part1/Cargo.toml
new file mode 100644
index 0000000..f14fe90
--- /dev/null
+++ b/2022/day3/part1/Cargo.toml
@@ -0,0 +1,9 @@
1[package]
2name = "part1"
3version = "0.1.0"
4edition = "2021"
5
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
8[dependencies]
9itertools = "0.10.5"
diff --git a/2022/day3/part1/src/main.rs b/2022/day3/part1/src/main.rs
new file mode 100644
index 0000000..2de2ce8
--- /dev/null
+++ b/2022/day3/part1/src/main.rs
@@ -0,0 +1,24 @@
1use std::collections::HashSet;
2
3fn main() {
4 let rucksacks: Vec<(&str, &str)> = include_str!("../../input")
5 .lines()
6 .map(|line| line.split_at(line.len() / 2))
7 .collect();
8
9 let mut sum = 0;
10 for (f, s) in rucksacks {
11 let first: HashSet<char> = HashSet::from_iter(f.chars());
12 let second: HashSet<char> = HashSet::from_iter(s.chars());
13
14 for x in first.intersection(&second) {
15 if x.is_lowercase() {
16 sum += *x as i16 - 96;
17 } else {
18 sum += *x as i16 - 38;
19 }
20 }
21 }
22
23 println!("{}", sum);
24}
diff --git a/2022/day3/part2/Cargo.toml b/2022/day3/part2/Cargo.toml
new file mode 100644
index 0000000..69fa504
--- /dev/null
+++ b/2022/day3/part2/Cargo.toml
@@ -0,0 +1,9 @@
1[package]
2name = "part2"
3version = "0.1.0"
4edition = "2021"
5
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
8[dependencies]
9itertools = "0.10.5"
diff --git a/2022/day3/part2/src/main.rs b/2022/day3/part2/src/main.rs
new file mode 100644
index 0000000..7139eb0
--- /dev/null
+++ b/2022/day3/part2/src/main.rs
@@ -0,0 +1,31 @@
1use itertools::Itertools;
2use std::collections::HashMap;
3use std::collections::HashSet;
4
5fn main() {
6 let mut sum = 0;
7 for group in &include_str!("../../input").lines().chunks(3) {
8 let mut membership: HashMap<char, usize> = HashMap::new();
9 for rucksack in group {
10 let mut items: HashSet<char> = HashSet::new();
11 for item in &rucksack.chars().chunks(2) {
12 for c in item {
13 items.insert(c);
14 }
15 }
16 for c in &items {
17 *membership.entry(c.to_owned()).or_default() += 1;
18 }
19 }
20 for (item, value) in membership {
21 if value == 3 {
22 if item.is_lowercase() {
23 sum += item as i16 - 96;
24 } else {
25 sum += item as i16 - 38;
26 }
27 }
28 }
29 }
30 println!("{}", sum);
31}