[Rust/2020/05] Add solution
This commit is contained in:
parent
5a0dfcb5cd
commit
aca99e0b9a
3 changed files with 43 additions and 2 deletions
|
@ -19,10 +19,10 @@
|
|||
|[**20**](https://adventofcode.com/2021/day/20) [<img height=12 src=".assets/rs.svg">](Rust/2021/20.rs "Rust solution for 2021/20") [<img height=12 src=".assets/py.svg">](Python/2021/20.ipynb "Python solution for 2021/20")|[**21**](https://adventofcode.com/2021/day/21) [<img height=12 src=".assets/rs.svg">](Rust/2021/21.rs "Rust solution for 2021/21") [<img height=12 src=".assets/py.svg">](Python/2021/21.ipynb "Python solution for 2021/21")|[**22**](https://adventofcode.com/2021/day/22) [<img height=12 src=".assets/rs.svg">](Rust/2021/22.rs "Rust solution for 2021/22") [<img height=12 src=".assets/py.svg">](Python/2021/22.ipynb "Python solution for 2021/22")|[**23**](https://adventofcode.com/2021/day/23) [<img height=12 src=".assets/rs.svg">](Rust/2021/23.rs "Rust solution for 2021/23") [<img height=12 src=".assets/py.svg">](Python/2021/23.ipynb "Python solution for 2021/23")|[**24**](https://adventofcode.com/2021/day/24) [<img height=12 src=".assets/rs.svg">](Rust/2021/24.rs "Rust solution for 2021/24") [<img height=12 src=".assets/py.svg">](Python/2021/24.ipynb "Python solution for 2021/24")|[**25**](https://adventofcode.com/2021/day/25) [<img height=12 src=".assets/rs.svg">](Rust/2021/25.rs "Rust solution for 2021/25") [<img height=12 src=".assets/py.svg">](Python/2021/25.ipynb "Python solution for 2021/25")|26|
|
||||
|27|28|29|30|31|||
|
||||
|
||||
## [2020](https://adventofcode.com/2020) ([<img height=18 src=".assets/py.svg"> Python](Python/2020): 25/25 | [<img height=18 src=".assets/rs.svg"> Rust](Rust/2020): 4/25)
|
||||
## [2020](https://adventofcode.com/2020) ([<img height=18 src=".assets/py.svg"> Python](Python/2020): 25/25 | [<img height=18 src=".assets/rs.svg"> Rust](Rust/2020): 5/25)
|
||||
|Mo|Tu|We|Th|Fr|Sa|Su|
|
||||
|-|-|-|-|-|-|-|
|
||||
||[**1**](https://adventofcode.com/2020/day/1) [<img height=12 src=".assets/rs.svg">](Rust/2020/01.rs "Rust solution for 2020/01") [<img height=12 src=".assets/py.svg">](Python/2020/01.ipynb "Python solution for 2020/01")|[**2**](https://adventofcode.com/2020/day/2) [<img height=12 src=".assets/rs.svg">](Rust/2020/02.rs "Rust solution for 2020/02") [<img height=12 src=".assets/py.svg">](Python/2020/02.ipynb "Python solution for 2020/02")|[**3**](https://adventofcode.com/2020/day/3) [<img height=12 src=".assets/rs.svg">](Rust/2020/03.rs "Rust solution for 2020/03") [<img height=12 src=".assets/py.svg">](Python/2020/03.ipynb "Python solution for 2020/03")|[**4**](https://adventofcode.com/2020/day/4) [<img height=12 src=".assets/rs.svg">](Rust/2020/04.rs "Rust solution for 2020/04") [<img height=12 src=".assets/py.svg">](Python/2020/04.ipynb "Python solution for 2020/04")|[**5**](https://adventofcode.com/2020/day/5) [<img height=12 src=".assets/py.svg">](Python/2020/05.ipynb "Python solution for 2020/05")|[**6**](https://adventofcode.com/2020/day/6) [<img height=12 src=".assets/py.svg">](Python/2020/06.ipynb "Python solution for 2020/06")|
|
||||
||[**1**](https://adventofcode.com/2020/day/1) [<img height=12 src=".assets/rs.svg">](Rust/2020/01.rs "Rust solution for 2020/01") [<img height=12 src=".assets/py.svg">](Python/2020/01.ipynb "Python solution for 2020/01")|[**2**](https://adventofcode.com/2020/day/2) [<img height=12 src=".assets/rs.svg">](Rust/2020/02.rs "Rust solution for 2020/02") [<img height=12 src=".assets/py.svg">](Python/2020/02.ipynb "Python solution for 2020/02")|[**3**](https://adventofcode.com/2020/day/3) [<img height=12 src=".assets/rs.svg">](Rust/2020/03.rs "Rust solution for 2020/03") [<img height=12 src=".assets/py.svg">](Python/2020/03.ipynb "Python solution for 2020/03")|[**4**](https://adventofcode.com/2020/day/4) [<img height=12 src=".assets/rs.svg">](Rust/2020/04.rs "Rust solution for 2020/04") [<img height=12 src=".assets/py.svg">](Python/2020/04.ipynb "Python solution for 2020/04")|[**5**](https://adventofcode.com/2020/day/5) [<img height=12 src=".assets/rs.svg">](Rust/2020/05.rs "Rust solution for 2020/05") [<img height=12 src=".assets/py.svg">](Python/2020/05.ipynb "Python solution for 2020/05")|[**6**](https://adventofcode.com/2020/day/6) [<img height=12 src=".assets/py.svg">](Python/2020/06.ipynb "Python solution for 2020/06")|
|
||||
|[**7**](https://adventofcode.com/2020/day/7) [<img height=12 src=".assets/py.svg">](Python/2020/07.ipynb "Python solution for 2020/07")|[**8**](https://adventofcode.com/2020/day/8) [<img height=12 src=".assets/py.svg">](Python/2020/08.ipynb "Python solution for 2020/08")|[**9**](https://adventofcode.com/2020/day/9) [<img height=12 src=".assets/py.svg">](Python/2020/09.ipynb "Python solution for 2020/09")|[**10**](https://adventofcode.com/2020/day/10) [<img height=12 src=".assets/py.svg">](Python/2020/10.ipynb "Python solution for 2020/10")|[**11**](https://adventofcode.com/2020/day/11) [<img height=12 src=".assets/py.svg">](Python/2020/11.ipynb "Python solution for 2020/11")|[**12**](https://adventofcode.com/2020/day/12) [<img height=12 src=".assets/py.svg">](Python/2020/12.ipynb "Python solution for 2020/12")|[**13**](https://adventofcode.com/2020/day/13) [<img height=12 src=".assets/py.svg">](Python/2020/13.ipynb "Python solution for 2020/13")|
|
||||
|[**14**](https://adventofcode.com/2020/day/14) [<img height=12 src=".assets/py.svg">](Python/2020/14.ipynb "Python solution for 2020/14")|[**15**](https://adventofcode.com/2020/day/15) [<img height=12 src=".assets/py.svg">](Python/2020/15.ipynb "Python solution for 2020/15")|[**16**](https://adventofcode.com/2020/day/16) [<img height=12 src=".assets/py.svg">](Python/2020/16.ipynb "Python solution for 2020/16")|[**17**](https://adventofcode.com/2020/day/17) [<img height=12 src=".assets/py.svg">](Python/2020/17.ipynb "Python solution for 2020/17")|[**18**](https://adventofcode.com/2020/day/18) [<img height=12 src=".assets/py.svg">](Python/2020/18.ipynb "Python solution for 2020/18")|[**19**](https://adventofcode.com/2020/day/19) [<img height=12 src=".assets/py.svg">](Python/2020/19.ipynb "Python solution for 2020/19")|[**20**](https://adventofcode.com/2020/day/20) [<img height=12 src=".assets/py.svg">](Python/2020/20.ipynb "Python solution for 2020/20")|
|
||||
|[**21**](https://adventofcode.com/2020/day/21) [<img height=12 src=".assets/py.svg">](Python/2020/21.ipynb "Python solution for 2020/21")|[**22**](https://adventofcode.com/2020/day/22) [<img height=12 src=".assets/py.svg">](Python/2020/22.ipynb "Python solution for 2020/22")|[**23**](https://adventofcode.com/2020/day/23) [<img height=12 src=".assets/py.svg">](Python/2020/23.ipynb "Python solution for 2020/23")|[**24**](https://adventofcode.com/2020/day/24) [<img height=12 src=".assets/py.svg">](Python/2020/24.ipynb "Python solution for 2020/24")|[**25**](https://adventofcode.com/2020/day/25) [<img height=12 src=".assets/py.svg">](Python/2020/25.ipynb "Python solution for 2020/25")|26|27|
|
||||
|
|
38
Rust/2020/05.rs
Normal file
38
Rust/2020/05.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#![feature(test)]
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
type Input = Vec<u32>;
|
||||
|
||||
fn setup(input: &str) -> Input {
|
||||
input
|
||||
.lines()
|
||||
.map(|line| {
|
||||
line.bytes().fold(0, |acc, c| {
|
||||
(acc << 1)
|
||||
| match c {
|
||||
b'F' | b'L' => 0,
|
||||
b'B' | b'R' => 1,
|
||||
_ => panic!(),
|
||||
}
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn part1(input: &Input) -> u32 {
|
||||
input.iter().copied().max().unwrap()
|
||||
}
|
||||
|
||||
fn part2(input: &Input) -> u32 {
|
||||
input
|
||||
.iter()
|
||||
.sorted_unstable()
|
||||
.tuple_windows()
|
||||
.find(|(&a, &b)| a + 1 != b)
|
||||
.unwrap()
|
||||
.0
|
||||
+ 1
|
||||
}
|
||||
|
||||
aoc::main!(2020, 5);
|
|
@ -48,6 +48,9 @@ path = "2020/03.rs"
|
|||
[[bin]]
|
||||
name = "2020_04"
|
||||
path = "2020/04.rs"
|
||||
[[bin]]
|
||||
name = "2020_05"
|
||||
path = "2020/05.rs"
|
||||
|
||||
# 2021
|
||||
[[bin]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue