This commit is contained in:
Max Nuding 2022-12-03 05:50:33 +00:00
parent 8ae82163b4
commit e54aad2d33
6 changed files with 366 additions and 10 deletions

3
.nova/Configuration.json Normal file
View File

@ -0,0 +1,3 @@
{
"editor.default_syntax" : "rust"
}

12
.nova/Tasks/Cargo.json Normal file
View File

@ -0,0 +1,12 @@
{
"buildBeforeRunning" : true,
"extension" : {
"identifier" : "com.kilb.rust",
"name" : "Rust"
},
"extensionTemplate" : "cargo",
"extensionValues" : {
},
"openLogOnRun" : "start"
}

16
Cargo.lock generated
View File

@ -25,6 +25,7 @@ name = "aoc-2022"
version = "0.1.0"
dependencies = [
"chrono",
"itertools",
"regex",
]
@ -127,6 +128,12 @@ dependencies = [
"syn",
]
[[package]]
name = "either"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "iana-time-zone"
version = "0.1.53"
@ -151,6 +158,15 @@ dependencies = [
"cxx-build",
]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "js-sys"
version = "0.3.60"

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
chrono = "0.4.23"
itertools = "0.10.5"
regex = "1.7.0"
[features]

300
input/03.txt Normal file
View File

@ -0,0 +1,300 @@
sfDRhjhHsHhgWPJvPmmQnmPqnW
pTddGVwcpMTTCdnQJqqQqqqVtVms
MdZCZGdcrCNRFZRhFssL
CttWnSnNfSnCHsWrTlTPPpPCTRrLpl
DgqqghjqJBVgDMTPGVlRGwbfLLGP
cgqBBhjqcBdMcWQcQNnNzsfv
lnDWMgTLlTFlHHgDDgngWFnlBWNcBQrdjcrrdQrPBrdjhWhj
JqSVRRVmmRqJJbZGGJqJvbmBNcjPNQNssQPhSSdwPwwwQr
b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HttThlHllvlzQpptzppl
DsCWdqLdDCnfJLSCqsqWRsBdlhjlhzlttzQhhtvlhnhhhbzT
JCWWRWCrLDDdBdLsSsLLSCrCNZMVcmMZMFwMZwNZPZVGFPmr
hhPzDzPhPNbfpzhBbdNbDhttzqWtwttHWwntjqmwmWFm
LgGZSdMMrgTLrZLdgLSgsGTFFjrWtFFmmmFtWjqHFnFtjn
vZgdLvZLZQLRQZQQdMZLdQvVpRhNNPfJDbcBbbhVNJNNhf

View File

@ -1,23 +1,47 @@
use crate::read;
fn val(c: char) -> u32 {
if c.is_lowercase() {
c as u32 - 96
} else {
26 + c as u32 - 64
}
}
pub fn run() {
let input = read("02");
let lines = input
.lines()
.map(|l| {
l
});
let input = read("03");
#[cfg(feature = "part1")]
{
let a = "TODO";
eprintln!("Day 2, Part 01: {}", a);
let lines: u32 = input
.lines()
.map(|l| {
let l = l.to_string();
let len = l.len() / 2;
let left = &l[0..len];
let right = &l[len..];
let lc = left.chars().find(|c| right.chars().any(|rc| rc == *c));
val(lc.unwrap())
})
.sum();
println!("Day 2, Part 01: {}", lines);
}
#[cfg(feature = "part2")]
{
let b = "TODO";
eprintln!("Day 2, Part 02: {}", b);
let lines: u32 = input.lines().collect::<Vec<_>>()[..] // Not a fan of collect here
.chunks(3)
.map(|l| {
let first = l[0];
let second = l[1];
let third = l[2];
let common = first
.chars()
.find(|f| second.chars().any(|s| s == *f) && third.chars().any(|t| t == *f));
val(common.unwrap())
})
.sum();
println!("Day 2, Part 02: {}", lines);
}
}