forked from akramer/advent
using anyhow::Result
This commit is contained in:
@@ -36,9 +36,10 @@ Of course, your expense report is much larger. Find the two entries that sum to
|
||||
do you get if you multiply them together?
|
||||
*/
|
||||
|
||||
use std::{fs::{File}, io};
|
||||
use std::fs::{File};
|
||||
use std::collections::HashSet;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use anyhow::Result;
|
||||
|
||||
fn find_triple(target: i32, list: &Vec<i32>, set: &HashSet<i32>) -> i32 {
|
||||
for i in list {
|
||||
@@ -63,7 +64,8 @@ fn find_pair(target: i32, list: &Vec<i32>, set: &HashSet<i32>) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
fn main() -> Result<()> {
|
||||
//let contents = fs::read_to_string("1.input").expect("Couldn't read \"1.input\"");
|
||||
let file = File::open("1.input")?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
@@ -71,7 +73,7 @@ fn main() -> io::Result<()> {
|
||||
let mut set: HashSet<i32> = HashSet::new();
|
||||
|
||||
for line in reader.lines() {
|
||||
let value = line.unwrap().parse::<i32>().unwrap();
|
||||
let value = line?.parse::<i32>()?;
|
||||
list.push(value);
|
||||
set.insert(value);
|
||||
}
|
||||
|
||||
3
src/main.rs
Normal file
3
src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in New Issue
Block a user