Skip to content

Instantly share code, notes, and snippets.

@jxn
Created December 14, 2018 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxn/ef6b2a8ee04ebfe4fc39b93c901e5bed to your computer and use it in GitHub Desktop.
Save jxn/ef6b2a8ee04ebfe4fc39b93c901e5bed to your computer and use it in GitHub Desktop.
aoc2018rust1
use std::fs;
fn main() {
let contents = fs::read_to_string("../data.txt").expect("couldn't get that file, sir");
let mut numbers = vec![];
for (_i, raw_number) in contents.split_whitespace().enumerate() {
let number = raw_number.parse::<i32>().expect("this ain't an int.");
numbers.push(number);
}
println!("{}", numbers.iter().sum::<i32>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment