summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-12-01 09:24:11 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-12-01 09:24:11 +0200
commit34bffc49705fb31f947ad0f2f45494dc9472e81b (patch)
treec9c9d4c374786cc1e89eff6a07ffcbd6ba65ee99 /src/main.rs
parentc98244df602a3f3d745f5971e22b1031c3e55770 (diff)
Day 1
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..0c24a73 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,12 @@
+use std::io;
+use std::io::prelude::*;
+
fn main() {
- println!("Hello, world!");
+ let stdin = io::stdin();
+ let answer = string_length_sum(stdin.lock().lines().map(|l| l.unwrap()));
+ dbg!(answer);
+}
+
+fn string_length_sum(it: impl Iterator<Item = String>) -> usize {
+ it.map(|l| l.len()).sum()
}