day06: Day 06: Custom Customs

Description Usage Arguments Details Value Examples

Description

Custom Customs

Usage

1
2
3

Arguments

x

some data

Details

Part One

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:

1
2
3
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
abc

a
b
c

ab
ac

a
a
a
a

b

This list represents answers from five groups:

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]title="Don't worry, nobody ever misreads just one word in real life." 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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
abc

a
b
c

ab
ac

a
a
a
a

b

This list represents answers from five groups:

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?

Value

For Part One, f06a(x) returns .... For Part Two, f06b(x) returns ....

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
x <- read_text_lines(
  drop_empty = "head/tail",
  x = "
  abc

  a
  b
  c

  ab
  ac

  a
  a
  a
  a

  b
  "
)
find_unique_questions(x)
find_shared_questions(x)

tjmahr/adventofcode20 documentation built on Dec. 31, 2020, 8:39 a.m.