[2018][rust][2] move from lib to bin

sorbet
Alpha Chen 6 years ago
parent 15953efb0f
commit 70fcbd804a

@ -1,4 +1,17 @@
pub fn solve(input: &str) -> String { use std::error::Error;
use std::io::{self, Read};
fn main() -> Result<(), Box<Error>> {
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
let output = solve(&input);
println!("{}", output);
Ok(())
}
fn solve(input: &str) -> String {
let box_ids: Vec<_> = input.lines().map(BoxId::new).collect(); let box_ids: Vec<_> = input.lines().map(BoxId::new).collect();
let two_count = box_ids.iter().filter(|&x| x.is_two()).count(); let two_count = box_ids.iter().filter(|&x| x.is_two()).count();

@ -1,12 +1,5 @@
use std::io::{self, Read}; use std::io::{self, Read};
mod day_01; mod day_01;
mod day_02;
fn main() { fn main() {}
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let output = day_02::solve(&input);
println!("{}", output);
}

Loading…
Cancel
Save