Skip to content

Commit

Permalink
add 2020 day 6
Browse files Browse the repository at this point in the history
  • Loading branch information
NimVek committed Nov 12, 2023
1 parent c33771b commit d0195ce
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![AoC 2017](https://img.shields.io/badge/2017-★_24-bcb01b)](https://adventofcode.com/2017)
[![AoC 2018](https://img.shields.io/badge/2018-★_9-fb7938)](https://adventofcode.com/2018)
[![AoC 2019](https://img.shields.io/badge/2019-★_6-f26e3c)](https://adventofcode.com/2019)
[![AoC 2020](https://img.shields.io/badge/2020-★_4-ec683f)](https://adventofcode.com/2020)
[![AoC 2020](https://img.shields.io/badge/2020-★_6-f26e3c)](https://adventofcode.com/2020)
[![AoC 2021](https://img.shields.io/badge/2021-★_50-44cc11)](https://adventofcode.com/2021)
[![AoC 2022](https://img.shields.io/badge/2022-★_50-44cc11)](https://adventofcode.com/2022)
[![AoC 2023](https://img.shields.io/badge/2023-★_0-9f9f9f)](https://adventofcode.com/2023)
Expand Down
3 changes: 3 additions & 0 deletions y2020/d06/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__year__ = 2020
__day__ = 6
__title__ = "Custom Customs"
15 changes: 15 additions & 0 deletions y2020/d06/cases/example.11.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
abc

a
b
c

ab
ac

a
a
a
a

b
3 changes: 3 additions & 0 deletions y2020/d06/cases/example.6..txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
abcx
abcy
abcz
37 changes: 37 additions & 0 deletions y2020/d06/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import functools
import operator

from aoc.lib.solution import SolutionBase

import logging


__all__ = ["Solution"]
__log__ = logging.getLogger(__name__)


class Solution(SolutionBase):
@staticmethod
def prepare(data):
if not any(isinstance(entry, list) for entry in data):
data = [data]
result = []
for entry in data:
if isinstance(entry, str):
result.append([set(entry)])
else:
result.append([set(e) for e in entry])
return tuple(result)

@staticmethod
def generic(data, function):
return sum(len(functools.reduce(function, entry)) for entry in data)

part_01 = functools.partial(generic, function=operator.__or__)
part_02 = functools.partial(generic, function=operator.__and__)


if __name__ == "__main__":
import aoc.lib.main

aoc.lib.main.main(Solution)

0 comments on commit d0195ce

Please sign in to comment.