diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-12-01 22:53:14 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-12-01 22:53:14 -0500 |
commit | b87a72594515f4a05aee7622db96269f2ee9c0af (patch) | |
tree | 02ad12632e4cafdbfd82f221f9a8350300ee4f43 /src/2020/1/mod.rs | |
parent | 2ce3804c08f8b49d8a921c07f02dba68df047e66 (diff) | |
download | advent-of-code-b87a72594515f4a05aee7622db96269f2ee9c0af.tar.gz advent-of-code-b87a72594515f4a05aee7622db96269f2ee9c0af.zip |
refactor
Diffstat (limited to 'src/2020/1/mod.rs')
-rw-r--r-- | src/2020/1/mod.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/2020/1/mod.rs b/src/2020/1/mod.rs new file mode 100644 index 0000000..8aa5290 --- /dev/null +++ b/src/2020/1/mod.rs @@ -0,0 +1,27 @@ +pub fn part1() -> anyhow::Result<()> { + let ints = crate::util::read_ints("data/1.txt")?; + for i in &ints { + for j in &ints { + if i + j == 2020 { + println!("{} * {} = {}", i, j, i * j); + return Ok(()); + } + } + } + Err(anyhow::anyhow!("no numbers summing to 2020 found")) +} + +pub fn part2() -> anyhow::Result<()> { + let ints = crate::util::read_ints("data/1.txt")?; + for i in &ints { + for j in &ints { + for k in &ints { + if i + j + k == 2020 { + println!("{} * {} * {} = {}", i, j, k, i * j * k); + return Ok(()); + } + } + } + } + Err(anyhow::anyhow!("no numbers summing to 2020 found")) +} |