abuse a nighly feature instead of a dependency

This commit is contained in:
2022-12-04 14:12:09 +01:00
parent f51e96b5d0
commit 510438a247
5 changed files with 8 additions and 31 deletions

18
Cargo.lock generated
View File

@@ -5,21 +5,3 @@ version = 3
[[package]] [[package]]
name = "aoc2022" name = "aoc2022"
version = "0.1.0" version = "0.1.0"
dependencies = [
"itertools",
]
[[package]]
name = "either"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]

View File

@@ -6,4 +6,3 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
itertools = "0.10.5"

2
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"

View File

@@ -1,5 +1,3 @@
use itertools::Itertools;
pub fn process_part_1(input: &str) -> u32 { pub fn process_part_1(input: &str) -> u32 {
input input
.lines() .lines()
@@ -23,16 +21,11 @@ pub fn process_part_1(input: &str) -> u32 {
pub fn process_part_2(input: &str) -> u32 { pub fn process_part_2(input: &str) -> u32 {
let result = input let result = input
.lines() .lines()
.chunks(3) .array_chunks::<3>()
.into_iter() .map(|[a, b, c]| {
.map(|chunk| { let overlap = a
let lines: Vec<_> = chunk .chars()
.map(|l| l.chars().unique().collect::<Vec<_>>()) .find(|chr| b.contains(*chr) && c.contains(*chr))
.collect();
let overlap = *lines[0]
.iter()
.find(|c| lines[1].contains(*c) && lines[2].contains(*c))
.unwrap(); .unwrap();
match overlap { match overlap {

View File

@@ -1,3 +1,4 @@
#![feature(iter_array_chunks)]
extern crate core; extern crate core;
pub mod day01; pub mod day01;