From 9f295fafddc2055706ac56555a84d55d5209a6cc Mon Sep 17 00:00:00 2001 From: Papaito Date: Wed, 2 Nov 2022 13:54:04 -0600 Subject: [PATCH] initial --- .gitignore | 1 + Cargo.lock | 7 +++++++ Cargo.toml | 8 ++++++++ cargo | 0 main.rs | 0 src/main.rs | 14 ++++++++++++++ 6 files changed, 30 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 cargo create mode 100644 main.rs create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..7d5e83d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "sum" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..924a80d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "sum" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/cargo b/cargo new file mode 100644 index 0000000..e69de29 diff --git a/main.rs b/main.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8aebf3e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,14 @@ +use std::io::{self, BufRead}; + +fn main() { + let stdin = io::stdin(); + let sum: u32 = stdin + .lock() + .lines() + .map(|line| -> u32 { + let num: u32 = line.unwrap().parse().unwrap_or(0); + num + }).sum(); + + println!("{}", sum); +} \ No newline at end of file