summaryrefslogtreecommitdiff
path: root/day2/src/main.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-12-05 19:46:06 +0100
committerSanto Cariotti <santo@dcariotti.me>2022-12-05 19:46:06 +0100
commitcf6303a5bc1558ebdb7b467da38f74cd3ac3a9b1 (patch)
tree6292cb239a8cf114179c6e7c8b3015840dfbae6e /day2/src/main.rs
parent6e10cc2773fcaff64902b13f44443da014f38be7 (diff)
Add 2022
Diffstat (limited to 'day2/src/main.rs')
-rw-r--r--day2/src/main.rs34
1 files changed, 0 insertions, 34 deletions
diff --git a/day2/src/main.rs b/day2/src/main.rs
deleted file mode 100644
index e0153a3..0000000
--- a/day2/src/main.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-use std::fs::File;
-use std::io::prelude::*;
-use std::io::BufReader;
-
-fn main() {
- let file = File::open("input.txt").unwrap();
- let reader = BufReader::new(&file);
- let tokens: Vec<String> = reader.lines().map(|x| x.unwrap()).collect::<Vec<String>>();
- let mut xpos: u32 = 0;
- let mut ypos: u32 = 0;
- let mut aim: u32 = 0;
-
- for line in tokens {
- let command: Vec<&str> = line.split(" ").collect();
- let (action, value) = (command[0], command[1].parse::<u32>().unwrap());
-
- match action {
- "forward" => {
- xpos += value;
- ypos += aim * value;
- }
- "down" => {
- // ypos += value;
- aim += value;
- }
- "up" => {
- // ypos -= value;
- aim -= value;
- }
- _ => {}
- }
- }
- println!("{}", ypos * xpos);
-}