Day03
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2021/day/3

Select binary numbers using the most and least common bit in each position.

Synopsis

Documentation

data B Source #

A bit

Constructors

B0 
B1 

cmpl :: B -> B Source #

Bit complement

fromBits :: [B] -> Integer Source #

Interpret list of bits as a big-endian binary number

>>> fromBits [B1, B1, B0, B1]
13

main :: IO () Source #

>>> :main
749376
2372923

pick1 :: ([B] -> B) -> [[B]] -> [B] Source #

Use selection function to pick output bit by column

pick2 :: ([B] -> B) -> [[B]] -> [B] Source #

Use selection function to filter entries by each bit column

harness :: (([B] -> B) -> [[B]] -> [B]) -> [[B]] -> Integer Source #

Given a function that requires a selection function run it on the selection function picking the most and least frequent values and then multiply those results together

rule :: [B] -> B Source #

Pick 1 when there are at least as many 1s as 0s