All Projects → ephemient → aoc2018

ephemient / aoc2018

Licence: BSD-3-Clause license
Advent of Code 2018 - my answers

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to aoc2018

adventofcode-2018
Advent of Code 2018
Stars: ✭ 28 (+115.38%)
Mutual labels:  advent-of-code, advent-of-code-2018
advent-of-code-2018
Learning rust from scratch
Stars: ✭ 19 (+46.15%)
Mutual labels:  advent-of-code, advent-of-code-2018
adventofcode
🎄 Advent of Code (2015-2021) in C#
Stars: ✭ 114 (+776.92%)
Mutual labels:  advent-of-code, advent-of-code-2018
adventofcode
Advent of Code solutions 2015-2021
Stars: ✭ 95 (+630.77%)
Mutual labels:  advent-of-code, advent-of-code-2018
adventofcode-solver
🎄 Advent of Code (2015-2021) in JavaScript
Stars: ✭ 16 (+23.08%)
Mutual labels:  advent-of-code, advent-of-code-2018
advent-of-code
My Advent of Code Solutions - 350/350 Stars
Stars: ✭ 30 (+130.77%)
Mutual labels:  advent-of-code, advent-of-code-2018
advent-of-code
My solutions for Advent of Code
Stars: ✭ 32 (+146.15%)
Mutual labels:  advent-of-code, advent-of-code-2018
AdventOfCode-Java
adventOfCode(Language.JAVA);
Stars: ✭ 15 (+15.38%)
Mutual labels:  advent-of-code, advent-of-code-2018
Scrypto-Advent-Calendar
Scrypto Advent Calendar. Learn the new programming langage to build secure DeFi applications quickly.
Stars: ✭ 22 (+69.23%)
Mutual labels:  advent-of-code
advent2019
Advent of Code 2019 solutions
Stars: ✭ 43 (+230.77%)
Mutual labels:  advent-of-code
coding challenge-24
Advent of Code 2019
Stars: ✭ 50 (+284.62%)
Mutual labels:  advent-of-code
advent-of-cljc
Cross platform Clojure Advent of Code solutions
Stars: ✭ 44 (+238.46%)
Mutual labels:  advent-of-code
advent-of-code-2021
🎄 My Advent of Code solutions in Rust. http://adventofcode.com/2021
Stars: ✭ 173 (+1230.77%)
Mutual labels:  advent-of-code
aoc-kotlin-starter
Starter template for solving Advent of Code in Kotlin
Stars: ✭ 15 (+15.38%)
Mutual labels:  advent-of-code
AdventOfCode2020
Solving Advent of Code 2020, each day in a different language
Stars: ✭ 22 (+69.23%)
Mutual labels:  advent-of-code
AdventOfCode2021
Solutions to all 25 AoC 2021 problems in Rust 🦀 Less than 100 lines per day and under 1 second total execution time. With competitive global leaderboard placements! 🎄
Stars: ✭ 34 (+161.54%)
Mutual labels:  advent-of-code
advent-of-code-2020
🎅🌟❄️☃️🎄🎁
Stars: ✭ 98 (+653.85%)
Mutual labels:  advent-of-code
advent-2017
Advent of Code 2017
Stars: ✭ 16 (+23.08%)
Mutual labels:  advent-of-code
advent-of-code
My solutions to Advent of Code in Clojure
Stars: ✭ 13 (+0%)
Mutual labels:  advent-of-code
aoc2021
Advent of Code 2021 - my answers
Stars: ✭ 25 (+92.31%)
Mutual labels:  advent-of-code

Advent of Code 2018

my answers in Haskell (see also Kotlin branch and Python gist)

Build Status

This project builds with The Haskell Tool Stack.

Setup:

curl -sSL https://get.haskellstack.org/ | sh -s -
stack setup

Run the HSpec test suite:

stack test aoc2018:test:aoc2018-test

Run criterion benchmarks:

stack bench aoc2018:bench:aoc2018-bench

Print solutions for the inputs provided in local data files:

stack build aoc2018:exe:aoc2018-exe --exec aoc2018-exe

Generate Haddock API documentation (rendered at ephemient.github.io/aoc2018):

stack haddock aoc2018:lib

Run hlint source code suggestions:

stack build hlint --exec 'hlint src test bench'

Day 1: Chronal Calibration

import Day1 (day1a, day1b)

Day 2: Inventory Management System

import Day2 (day2a, day2b)

Day 3: No Matter How You Slice It

import Day3 (day3a, day3b)

Day 4: Repose Record

import Day4 (day4a, day4b)

Day 5: Alchemical Reaction

import Day5 (day5a, day5b)

Day 6: Chronal Coordinates

import Day6 (day6a, day6b)

Day 7: The Sum of Its Parts

import Day7 (day7a, day7b)

Day 8: Memory Maneuver

import Day8 (day8a, day8b)

Day 9: Marble Mania

import Day9 (day9a, day9b)

Day 10: The Stars Align

import Day10 (day10)

Day 11: Chronal Charge

import Day11 (day11a, day11b)

Day 12: Subterranean Sustainability

import Day12 (day12)

Day 13: Mine Cart Madness

import Day13 (day13a, day13b)

Day 14: Chocolate Charts

import Day14 (day14a, day14b)

Day 15: Beverage Bandits

import Day15 (day15a, day15b)

Day 16: Chronal Classification

import Day16 (day16a, day16b)

Day 17: Reservoir Research

import Day17 (day17a, day17b)

Day 18: Settlers of The North Pole

import Day18 (day18)

Day 19: Go With The Flow

import Day19 (day19)

Day 20: A Regular Map

import Day20 (day20a, day20b)

Day 21: Chronal Conversion

import Day21 (day21a, day21b)

Day 22: Mode Maze

import Day22 (day22a, day22b)

Day 23: Experimental Emergency Teleportation

import Day23 (day23a, day23b)

Day 24: Immune System Simulator 20XX

import Day24 (day24a, day24b)

Day 25: Four-Dimensional Adventure

import Day25 (day25a)

import Control.Monad (when)
import Data.Maybe (mapMaybe)
import Paths_aoc2018 (getDataFileName)
import System.Environment (getArgs)
import Text.Read (readMaybe)

getDayInput :: Int -> IO String
getDayInput i = getDataFileName ("day" ++ show i ++ ".txt") >>= readFile

readDayInput :: (Read a) => Int -> IO a
readDayInput = fmap read . getDayInput

maybeBottom :: (a -> String) -> Maybe a -> String
maybeBottom = maybe "(⊥)"

showError :: (Show a) => (b -> String) -> Either a b -> String
showError = either (\err -> "(" ++ show err ++ ")")

run :: Int -> (Int -> IO a) -> (b -> IO ()) -> [a -> b] -> IO ()
run day readIO showIO funcs = do
    days <- mapMaybe readMaybe <$> getArgs
    when (null days || day `elem` days) $ do
    putStrLn $ "Day " ++ show day
    contents <- readIO day
    mapM_ (showIO . ($ contents)) funcs
    putStrLn ""

main :: IO ()
main = do
    run 1 getDayInput putStrLn [show . day1a, maybeBottom show . day1b]
    run 2 getDayInput putStrLn [show . day2a, maybeBottom id . day2b]
    run 3 getDayInput (putStrLn . maybeBottom show) [day3a, day3b]
    run 4 getDayInput (putStrLn . maybeBottom show) [day4a, day4b]
    run 5 getDayInput print [day5a, day5b]
    run 6 getDayInput (putStrLn . maybeBottom show) [day6a, day6b 10000]
    run 7 getDayInput putStrLn [day7a, show . day7b 60 5]
    run 8 getDayInput (putStrLn . maybeBottom show) [day8a, day8b]
    run 9 getDayInput (putStrLn . maybeBottom show) [day9a, day9b]
    run 10 getDayInput (putStrLn . maybeBottom (\(i, s) -> s ++ show i)) [day10]
    run 11 getDayInput putStrLn [day11a, day11b]
    run 12 getDayInput (putStrLn . maybeBottom show) [day12 20, day12 50000000000]
    run 13 getDayInput putStrLn [day13a, day13b]
    run 14 getDayInput putStrLn [day14a, show . day14b]
    run 15 getDayInput (print . uncurry (*)) [day15a, snd . day15b]
    run 16 getDayInput (putStrLn . maybeBottom show) [day16a, day16b]
    run 17 getDayInput (putStrLn . maybeBottom show) [day17a, day17b]
    run 18 getDayInput print [day18 10, day18 1000000000]
    run 19 getDayInput (putStrLn . maybeBottom show) [day19 0, day19 1]
    run 20 getDayInput print [day20a, day20b]
    run 21 getDayInput (putStrLn . maybeBottom show) [day21a, day21b]
    run 22 getDayInput (putStrLn . maybeBottom show) [day22a, day22b]
    run 23 getDayInput (putStrLn . maybeBottom show) [day23a, day23b]
    run 24 getDayInput (putStrLn . maybeBottom show) [day24a, day24b]
    run 25 getDayInput print [day25a]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].