Compare commits

..

No commits in common. "99001d75b553eafa92e1118c3120b81cc364ad1a" and "59f67f1c645f0618a0b229edebfb7e13d107f13f" have entirely different histories.

5 changed files with 22 additions and 2442 deletions

View File

@ -4,93 +4,58 @@
``` ```
AOC 2020 AOC 2020
Day 1 - Part 1 - binary : 1006875 Day 1 - Part 1 - binary : 1006875
generator: 11.964µs, generator: 12.539µs,
runner: 426ns runner: 373ns
Day 1 - Part 1 - linear : 1006875 Day 1 - Part 1 - linear : 1006875
generator: 4.589µs, generator: 4.945µs,
runner: 7.476µs runner: 7.727µs
Day 1 - Part 1 - set : 1006875 Day 1 - Part 1 - set : 1006875
generator: 16.535µs, generator: 16.721µs,
runner: 1.799µs runner: 1.288µs
Day 1 - Part 2 : 165026160 Day 1 - Part 2 : 165026160
generator: 4.114µs, generator: 4.272µs,
runner: 1.36052ms runner: 1.225545ms
``` ```
## Day 2 ## Day 2
``` ```
AOC 2020 AOC 2020
Day 2 - Part 1 : 640 Day 2 - Part 1 : 640
generator: 1.616953ms, generator: 1.732103ms,
runner: 103.011µs runner: 100.802µs
Day 2 - Part 1 - handrolled : 640 Day 2 - Part 1 - handrolled : 640
generator: 184.009µs, generator: 157.527µs,
runner: 101.57µs runner: 97.775µs
Day 2 - Part 2 : 472 Day 2 - Part 2 : 472
generator: 1.352896ms, generator: 1.374162ms,
runner: 9.793µs runner: 10.461µs
``` ```
## Day 3 ## Day 3
``` ```
AOC 2020 AOC 2020
Day 3 - Part 1 : 148 Day 3 - Part 1 : 148
generator: 53.226µs, generator: 40.059µs,
runner: 3.183µs runner: 1.345µs
Day 3 - Part 2 : 727923200 Day 3 - Part 2 : 727923200
generator: 44.07µs, generator: 95.265µs,
runner: 11.708µs runner: 6.908µs
``` ```
## Day 4 ## Day 4
``` ```
AOC 2020 AOC 2020
Day 4 - Part 1 : 239 Day 4 - Part 1 : 239
generator: 411.607µs, generator: 366.249µs,
runner: 1.791µs runner: 1.566µs
Day 4 - Part 2 : 188 Day 4 - Part 2 : 188
generator: 345.307µs, generator: 315.706µs,
runner: 45.897µs runner: 39.195µs
``` ```
## Day 5
```
AOC 2020
Day 5 - Part 1 - glenng : 989
generator: 217ns,
runner: 73.448µs
Day 5 - Part 1 - wathiede : 989
generator: 77.612µs,
runner: 459ns
Day 5 - Part 2 - wathiede : 548
generator: 79.544µs,
runner: 27.281µs
```
## Day 6
```
AOC 2020
Day 6 - Part 1 : 6930
generator: 260ns,
runner: 541.694µs
Day 6 - Part 2 : 3585
generator: 138ns,
runner: 1.897184ms
```

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
MAX_DAY=$(ls src/day* | tr -d 'a-z/. ' | sort -n | tail -1)
(
echo "# Results"
echo
for day in $(seq 1 ${MAX_DAY:?});
do
echo "## Day ${day:?}"
echo "\`\`\`"
cargo aoc -d ${day:?} 2> /dev/null
echo "\`\`\`"
echo
done) > README.md

View File

@ -1,134 +0,0 @@
//! --- Day 6: Custom Customs ---
//! As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers.
//!
//! The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone in your group answers "yes". Since your group is just you, this doesn't take very long.
//!
//! However, the person sitting next to you seems to be experiencing a language barrier and asks if you can help. For each of the people in their group, you write down the questions for which they answer "yes", one per line. For example:
//!
//! abcx
//! abcy
//! abcz
//! In this group, there are 6 questions to which anyone answered "yes": a, b, c, x, y, and z. (Duplicate answers to the same question don't count extra; each question counts at most once.)
//!
//! Another group asks for your help, then another, and eventually you've collected answers from every group on the plane (your puzzle input). Each group's answers are separated by a blank line, and within each group, each person's answers are on a single line. For example:
//!
//! abc
//!
//! a
//! b
//! c
//!
//! ab
//! ac
//!
//! a
//! a
//! a
//! a
//!
//! b
//! This list represents answers from five groups:
//!
//! The first group contains one person who answered "yes" to 3 questions: a, b, and c.
//! The second group contains three people; combined, they answered "yes" to 3 questions: a, b, and c.
//! The third group contains two people; combined, they answered "yes" to 3 questions: a, b, and c.
//! The fourth group contains four people; combined, they answered "yes" to only 1 question, a.
//! The last group contains one person who answered "yes" to only 1 question, b.
//! In this example, the sum of these counts is 3 + 3 + 3 + 1 + 1 = 11.
//!
//! For each group, count the number of questions to which anyone answered "yes". What is the sum of those counts?
//!
//! --- Part Two ---
//! As you finish the last group's customs declaration, you notice that you misread one word in the instructions:
//!
//! You don't need to identify the questions to which anyone answered "yes"; you need to identify the questions to which everyone answered "yes"!
//!
//! Using the same example as above:
//!
//! abc
//!
//! a
//! b
//! c
//!
//! ab
//! ac
//!
//! a
//! a
//! a
//! a
//!
//! b
//! This list represents answers from five groups:
//!
//! In the first group, everyone (all 1 person) answered "yes" to 3 questions: a, b, and c.
//! In the second group, there is no question to which everyone answered "yes".
//! In the third group, everyone answered yes to only 1 question, a. Since some people did not answer "yes" to b or c, they don't count.
//! In the fourth group, everyone answered yes to only 1 question, a.
//! In the fifth group, everyone (all 1 person) answered "yes" to 1 question, b.
//! In this example, the sum of these counts is 3 + 0 + 1 + 1 + 1 = 6.
//!
//! For each group, count the number of questions to which everyone answered "yes". What is the sum of those counts?
use std::collections::HashSet;
use aoc_runner_derive::aoc;
#[aoc(day6, part1)]
fn solution1(input: &str) -> usize {
input
.split("\n\n")
.map(|group| group.chars().filter(|c| c != &'\n').collect::<HashSet<_>>())
.map(|set| set.len())
.sum()
}
#[aoc(day6, part2)]
fn solution2(input: &str) -> usize {
input
.split("\n\n")
.map(|group| {
let sets = group
.split('\n')
.map(|p| p.chars().collect::<HashSet<_>>())
.collect::<Vec<_>>();
// Find letters common to all sets int this group.
sets.iter().fold(sets.first().unwrap().clone(), |acc, s| {
acc.intersection(s).cloned().collect()
})
})
.map(|set| set.len())
.sum()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &'static str = r#"abc
a
b
c
ab
ac
a
a
a
a
b"#;
#[test]
fn part1() {
assert_eq!(solution1(INPUT), 11);
}
#[test]
fn part2() {
assert_eq!(solution2(INPUT), 6);
}
}

View File

@ -3,7 +3,6 @@ mod day2;
mod day3; mod day3;
mod day4; mod day4;
mod day5; mod day5;
mod day6;
use aoc_runner_derive::aoc_lib; use aoc_runner_derive::aoc_lib;