aboutsummaryrefslogtreecommitdiff
path: root/2022/13/a.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/13/a.rs')
-rw-r--r--2022/13/a.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/2022/13/a.rs b/2022/13/a.rs
new file mode 100644
index 0000000..c849bef
--- /dev/null
+++ b/2022/13/a.rs
@@ -0,0 +1,21 @@
1use std::cmp::Ordering;
2mod common;
3use common::*;
4
5fn main() {
6 let mut line = String::new();
7 let mut sum = 0;
8 let mut i = 0;
9 loop {
10 i += 1;
11 let _ = std::io::stdin().read_line(&mut line).unwrap();
12 let p = parse(line.as_bytes());
13 line.clear();
14 let _ = std::io::stdin().read_line(&mut line).unwrap();
15 let q = parse(line.as_bytes());
16 if compare(&p, &q) != Ordering::Greater { sum += i; }
17 if std::io::stdin().read_line(&mut line).unwrap() == 0 { break; }
18 line.clear();
19 }
20 println!("{sum}");
21}

Generated with cgit - Back to sebastiano.tronto.net