Compare commits
No commits in common. "b61d9951a698056cb2b0beab34529711e574bdec" and "c5f772054ebf42f3bf89a21f2409500d17e663d7" have entirely different histories.
b61d9951a6
...
c5f772054e
7
day2/Cargo.lock
generated
7
day2/Cargo.lock
generated
@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "day2"
|
|
||||||
version = "0.1.0"
|
|
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "day2"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
2500
day2/input.txt
2500
day2/input.txt
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
|||||||
use std::env;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::BufReader;
|
|
||||||
use std::io::BufRead;
|
|
||||||
|
|
||||||
fn score(line: String) -> i64 {
|
|
||||||
match line.trim() {
|
|
||||||
"A X" => 3 + 0,
|
|
||||||
"A Y" => 1 + 3,
|
|
||||||
"A Z" => 2 + 6,
|
|
||||||
"B X" => 1 + 0,
|
|
||||||
"B Y" => 2 + 3,
|
|
||||||
"B Z" => 3 + 6,
|
|
||||||
"C X" => 2 + 0,
|
|
||||||
"C Y" => 3 + 3,
|
|
||||||
"C Z" => 1 + 6,
|
|
||||||
_other => 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let args: Vec<String> = env::args().collect();
|
|
||||||
let input = &args[1];
|
|
||||||
let reader = BufReader::new(File::open(input).expect("where file?"));
|
|
||||||
|
|
||||||
let mut sum = 0;
|
|
||||||
for line in reader.lines() {
|
|
||||||
sum += score(line.unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Sum: {}", sum);
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
use std::env;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::BufReader;
|
|
||||||
use std::io::BufRead;
|
|
||||||
|
|
||||||
fn score(line: String) -> i64 {
|
|
||||||
match line.trim() {
|
|
||||||
"A X" => 1 + 3,
|
|
||||||
"A Y" => 2 + 6,
|
|
||||||
"A Z" => 3 + 0,
|
|
||||||
"B X" => 1 + 0,
|
|
||||||
"B Y" => 2 + 3,
|
|
||||||
"B Z" => 3 + 6,
|
|
||||||
"C X" => 1 + 6,
|
|
||||||
"C Y" => 2 + 0,
|
|
||||||
"C Z" => 3 + 3,
|
|
||||||
_other => 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let args: Vec<String> = env::args().collect();
|
|
||||||
let input = &args[1];
|
|
||||||
let reader = BufReader::new(File::open(input).expect("where file?"));
|
|
||||||
|
|
||||||
let mut sum = 0;
|
|
||||||
for line in reader.lines() {
|
|
||||||
sum += score(line.unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Sum: {}", sum);
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
A Y
|
|
||||||
B X
|
|
||||||
C Z
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user