delete accidental submodule
This commit is contained in:
54
old/day12/src/main.rs
Normal file
54
old/day12/src/main.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use std::fs;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
fn main() {
|
||||
let input = parse_input();
|
||||
|
||||
for (springs, groups) in input {
|
||||
println!("{:?} {:?}", springs, groups);
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_input() -> Vec<(Vec<Condition>, Vec<i32>)> {
|
||||
let input = fs::read_to_string("input.txt").unwrap();
|
||||
let input: Vec<(Vec<Condition>, Vec<i32>)> = input.split('\n')
|
||||
.map(|line| {
|
||||
line.split(' ')
|
||||
.collect_tuple()
|
||||
.unwrap()
|
||||
}).map(|(springs, groups)| {
|
||||
let springs: Vec<Condition> = springs.chars()
|
||||
.map(|char| {
|
||||
char.to_condition()
|
||||
}).collect();
|
||||
|
||||
let groups: Vec<_> = groups.split(',')
|
||||
.map(|num| num.parse::<i32>().expect("Failed to parse group len"))
|
||||
.collect();
|
||||
(springs, groups)
|
||||
}).collect();
|
||||
input
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Condition {
|
||||
Good,
|
||||
Bad,
|
||||
WhoKnows
|
||||
}
|
||||
|
||||
trait ConditionConvertable {
|
||||
fn to_condition(self) -> Condition;
|
||||
}
|
||||
|
||||
impl ConditionConvertable for char {
|
||||
fn to_condition(self) -> Condition {
|
||||
match self {
|
||||
'.' => Condition::Good,
|
||||
'#' => Condition::Bad,
|
||||
'?' => Condition::WhoKnows,
|
||||
_ => panic!("Invalid spring char AHHH")
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user