forked from akramer/advent
finished day 1
This commit is contained in:
commit
0a6beb9bb6
200
1.input
Normal file
200
1.input
Normal file
@ -0,0 +1,200 @@
|
||||
1946
|
||||
1859
|
||||
1654
|
||||
1806
|
||||
1648
|
||||
1873
|
||||
1216
|
||||
1831
|
||||
1610
|
||||
1779
|
||||
1626
|
||||
1332
|
||||
1713
|
||||
1919
|
||||
1353
|
||||
1720
|
||||
1818
|
||||
1976
|
||||
1993
|
||||
1617
|
||||
1678
|
||||
1655
|
||||
1725
|
||||
1686
|
||||
1737
|
||||
1696
|
||||
1046
|
||||
1814
|
||||
1909
|
||||
1618
|
||||
2006
|
||||
1903
|
||||
1528
|
||||
1635
|
||||
1457
|
||||
1924
|
||||
1734
|
||||
1723
|
||||
1735
|
||||
1984
|
||||
1846
|
||||
1921
|
||||
1587
|
||||
2009
|
||||
1607
|
||||
1987
|
||||
1910
|
||||
1571
|
||||
1898
|
||||
1869
|
||||
1537
|
||||
1446
|
||||
1535
|
||||
1802
|
||||
1847
|
||||
1966
|
||||
1944
|
||||
1793
|
||||
1383
|
||||
1850
|
||||
1274
|
||||
347
|
||||
1208
|
||||
1748
|
||||
1906
|
||||
1771
|
||||
1849
|
||||
1773
|
||||
1792
|
||||
1705
|
||||
1538
|
||||
1564
|
||||
2003
|
||||
1994
|
||||
1545
|
||||
1704
|
||||
1657
|
||||
1483
|
||||
1701
|
||||
1724
|
||||
1293
|
||||
1834
|
||||
1712
|
||||
1950
|
||||
1844
|
||||
1290
|
||||
1692
|
||||
1820
|
||||
1585
|
||||
1986
|
||||
1328
|
||||
1841
|
||||
1709
|
||||
1232
|
||||
1945
|
||||
1684
|
||||
1787
|
||||
1991
|
||||
1914
|
||||
16
|
||||
1977
|
||||
1620
|
||||
1825
|
||||
1866
|
||||
1615
|
||||
1832
|
||||
496
|
||||
1932
|
||||
1819
|
||||
1559
|
||||
1870
|
||||
1677
|
||||
1650
|
||||
1594
|
||||
1664
|
||||
1600
|
||||
1622
|
||||
1862
|
||||
1937
|
||||
1624
|
||||
1580
|
||||
1931
|
||||
1803
|
||||
1839
|
||||
1755
|
||||
1952
|
||||
1473
|
||||
1694
|
||||
1864
|
||||
1178
|
||||
1163
|
||||
1790
|
||||
393
|
||||
1776
|
||||
1871
|
||||
1999
|
||||
1923
|
||||
1174
|
||||
1557
|
||||
1646
|
||||
1200
|
||||
1842
|
||||
1432
|
||||
1573
|
||||
1913
|
||||
1954
|
||||
1599
|
||||
1980
|
||||
1948
|
||||
1430
|
||||
1298
|
||||
1835
|
||||
1643
|
||||
1742
|
||||
1609
|
||||
1649
|
||||
1382
|
||||
1343
|
||||
1263
|
||||
1908
|
||||
1703
|
||||
1922
|
||||
1764
|
||||
1603
|
||||
1330
|
||||
588
|
||||
954
|
||||
1772
|
||||
1553
|
||||
975
|
||||
1499
|
||||
1552
|
||||
1214
|
||||
1829
|
||||
1698
|
||||
1797
|
||||
1807
|
||||
1961
|
||||
1947
|
||||
1845
|
||||
1881
|
||||
1821
|
||||
1815
|
||||
1623
|
||||
1675
|
||||
1478
|
||||
1886
|
||||
1951
|
||||
1700
|
||||
1890
|
||||
1876
|
||||
1781
|
||||
1853
|
||||
1983
|
||||
1901
|
||||
1939
|
||||
1292
|
||||
853
|
||||
1879
|
||||
1652
|
||||
5
Cargo.lock
generated
Normal file
5
Cargo.lock
generated
Normal file
@ -0,0 +1,5 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "advent"
|
||||
version = "0.1.0"
|
||||
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "advent"
|
||||
version = "0.1.0"
|
||||
authors = ["adamkramer"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
57
src/bin/1.rs
Normal file
57
src/bin/1.rs
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
--- Day 1: Report Repair ---
|
||||
|
||||
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a
|
||||
tropical island. Surely, Christmas will go on without you.
|
||||
|
||||
The tropical island has its own currency and is entirely cash-only. The gold coins used there have
|
||||
a little picture of a starfish; the locals just call them stars. None of the currency exchanges
|
||||
seem to have heard of them, but somehow, you'll need to find fifty of these coins by the time you
|
||||
arrive so you can pay the deposit on your room.
|
||||
|
||||
To save your vacation, you need to get all fifty stars by December 25th.
|
||||
|
||||
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent
|
||||
calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star.
|
||||
Good luck!
|
||||
|
||||
Before you leave, the Elves in accounting just need you to fix your expense report (your puzzle
|
||||
input); apparently, something isn't quite adding up.
|
||||
|
||||
Specifically, they need you to find the two entries that sum to 2020 and then multiply those two
|
||||
numbers together.
|
||||
|
||||
For example, suppose your expense report contained the following:
|
||||
|
||||
1721
|
||||
979
|
||||
366
|
||||
299
|
||||
675
|
||||
1456
|
||||
In this list, the two entries that sum to 2020 are 1721 and 299. Multiplying them together
|
||||
produces 1721 * 299 = 514579, so the correct answer is 514579.
|
||||
|
||||
Of course, your expense report is much larger. Find the two entries that sum to 2020; what
|
||||
do you get if you multiply them together?
|
||||
*/
|
||||
|
||||
use std::{fs::{File}, io};
|
||||
use std::collections::HashSet;
|
||||
use std::io::{BufRead, BufReader};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
//let contents = fs::read_to_string("1.input").expect("Couldn't read \"1.input\"");
|
||||
let file = File::open("1.input")?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
let mut list: Vec<i32> = Vec::new();
|
||||
let mut set: HashSet<i32> = HashSet::new();
|
||||
|
||||
for line in reader.lines() {
|
||||
let value = line.unwrap().parse::<i32>().unwrap();
|
||||
list.push(value);
|
||||
set.insert(value);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user