aoc2015

package
v0.0.0-...-d783ee6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2020 License: MIT Imports: 16 Imported by: 0

README

= Advent of Code 2015

== Progress

* [*] Day 1: Not Quite Lisp
* [*] Day 2: I Was Told There Would Be No Math
* [*] Day 3: Perfectly Spherical Houses in a Vacuum
* [*] Day 4: The Ideal Stocking Stuffer
* [*] Day 5: Doesn’t He Have Intern-Elves For This?
* [*] Day 6: Probably a Fire Hazard
* [*] Day 7: Some Assembly Required
* [*] Day 8: Matchsticks
* [*] Day 9: All in a Single Night
* [*] Day 10: Elves Look, Elves Say
* [*] Day 11: Corporate Policy
* [*] Day 12: JSAbacusFramework.io
* [*] Day 13: Knights of the Dinner Table
* [*] Day 14: Reindeer Olympics
* [ ] Day 15: Science for Hungry People
* [*] Day 16: Aunt Sue
* [*] Day 17: No Such Thing as Too Much
* [ ] Day 18: Like a GIF For Your Yard
* [ ] Day 19: Medicine for Rudolph
* [*] Day 20: Infinite Elves and Infinite Houses
* [ ] Day 21: RPG Simulator 20XX
* [ ] Day 22: Wizard Simulator 20XX
* [ ] Day 23: Opening the Turing Lock
* [ ] Day 24: It Hangs in the Balance
* [ ] Day 25: Let It Snow

Documentation

Overview

Package aoc2015 implements the solutions for Advent of Code 2015.

Index

Constants

This section is empty.

Variables

AllSolutions is the slice of all solutions so that they may be indexed easily. Note that slice index starts at 0 and not 1 so AllSolutions[0] is the solution for Day 1.

Functions

func Day01

func Day01(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day01 solves the first day puzzle "Not Quite Lisp".

Input

A single line of length 7000 containing nothing but the characters ')' and '('. For example:

()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((

If there exists any character that is neither a '(' or a ')', return an error.

func Day02

func Day02(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day02 solves the second day puzzle "I Was Told There Would Be No Math".

Input

A file containing 1000 lines, each of which is in the format LxWxH, where L, W, and H are positive integers no more than 32, and x is the character 'x'. For example:

7x4x10
22x24x29
30x1x2
19x2x5
11x9x22
23x15x10
11x11x10
30x28x5
22x5x4
6x26x20
16x12x30
10x20x5
25x14x24
16x17x22
11x28x26
1x11x10

If there is more than or less than three numbers in a row, or if there are issues with parsing the input, the function will return an error corresponding to the problematic line. If the numbers are too large, that may result in an integer overflow.

func Day03

func Day03(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day03 solves the third day puzzle "Perfectly Spherical Houses in a Vacuum".

Input

A single line of length 8192 containing only the characters '<', '>', '^', and 'v', each representing direction. For example:

v^>>v>v>>>>^^>v<^v^>><<^<>>v><^><<^>^<vv^^<><<>><vvvv^>^^<><^^

Any characters that are not any of those will be ignored.

func Day04

func Day04(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day04 solves the fourth day puzzle "The Ideal Stocking Stuffer".

Input

A string of length 8 containing only the lowercase letters 'a' to 'z'. For example:

iwrupvqb

Because this is more or less a brute-force solution, it may take a long time before returning an answer.

func Day04ST

func Day04ST(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day04ST solves the fourth day puzzle "The Ideal Stocking Stuffer" but is a single-threaded solution.

func Day05

func Day05(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day05 solves the fifth day puzzle "Doesn't He Have Intern-Elves For This?".

Input

A file containing 1000 lines each of length 16 only containing the lowercase letters 'a' to 'z'. For example:

zvnvprxxjkhnkkpq
nejwxbhjxxdbenid
chryiccsebdbcnkc
guoeefaeafhlgvxh
nzapxrfrrqhsingx
mkzvquzvqvwsejqs
kozmlmbchydtxeeo
keylygnoqhmfzrfp
srwzoxccndoxylxe
uqjzalppoorosxxo
potmkinyuqxsfdfw
qkkwrhpbhypxhiun
wgfvnogarjmdbxyh

func Day05ST

func Day05ST(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day05ST solves the fifth day puzzle "Doesn't He Have Intern-Elves For This?" but is a single-threaded solution.

func Day06

func Day06(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day06 solves the sixth day puzzle "Probably a Fire Hazard".

Input

A file containing 300 lines, each of which is an "instruction" that determines which lights to turn off, turn on, or toggle on a 1000x1000 grid. For example:

turn on 818,296 through 818,681
turn on 71,699 through 91,960
turn off 838,578 through 967,928
toggle 440,856 through 507,942

Each instruction is guaranteed to be valid where each instructions is prefixed by "turn on", "turn off", or "toggle", the first coordinate is no greater than the third one and the second no greater than the fourth, and all numbers are no greater than 999. Invalid inputs will cause an error to return.

func Day07

func Day07(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day07 solves the seventh day puzzle "Some Assembly Required".

Input

A file containing several lines where each line represents an instruction. An instruction can be any of the following:

Assignment instruction

VALUE -> IDENT
123 -> x

AND instruction

IDENT AND IDENT -> IDENT
x AND y -> z

OR instruction

IDENT OR IDENT -> IDENT
bj OR bi -> bk

NOT instruction

NOT IDENT -> IDENT
NOT e -> f

LSHIFT instruction

IDENT LSHIFT VALUE -> IDENT
p LSHIFT 2 -> q

RSHIFT instruction

IDENT RSHIFT VALUE -> IDENT
p RSHIFT 2 -> q

Note that IDENT is any alphabetic string at most length 2 that represents a Signal, a 16-bit unsigned integer, and VALUE represents a raw Signal. Also note that VALUE is only a parameter for the LSHIFT, RSHIFT, and Assignment instructions.

func Day08

func Day08(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day08 solves the eighth day puzzle "Matchsticks".

Input

A file containing 300 lines where each line represents a "string literal", which contains combinations such as '\"' and '\x27'. For example:

"ubgxxcvnltzaucrzg\\xcez"
"pnocjvo\\yt"
"fcabrtqog\"a\"zj"
"o\\bha\\mzxmrfltnflv\xea"
"isos\x6azbnkojhxoopzetbj\xe1yd"

Each line is observed to start and end with a double-quotation mark '"'. If it does, trim the quotation marks away. If it doesn't, take the input as-is.

func Day09

func Day09(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day09 solves the ninth day puzzle "All in a Single Night".

Input

A file describing the distances between any two towns of a graph containing seven towns. For example:

Faerun to Norrath = 129
Faerun to Tristram = 58
Faerun to AlphaCentauri = 13
Faerun to Arbre = 24
Faerun to Snowdin = 60
Faerun to Tambi = 71
Faerun to Straylight = 67
Norrath to Tristram = 142
Norrath to AlphaCentauri = 15
Norrath to Arbre = 135
Norrath to Snowdin = 75
Norrath to Tambi = 82
Norrath to Straylight = 54
Tristram to AlphaCentauri = 118
Tristram to Arbre = 122
Tristram to Snowdin = 103
Tristram to Tambi = 49
Tristram to Straylight = 97
AlphaCentauri to Arbre = 116
AlphaCentauri to Snowdin = 12
AlphaCentauri to Tambi = 18
AlphaCentauri to Straylight = 91
Arbre to Snowdin = 129
Arbre to Tambi = 53
Arbre to Straylight = 40
Snowdin to Tambi = 15
Snowdin to Straylight = 99
Tambi to Straylight = 70

The above is my complete input. It is guaranteed that the distances betwen any two towns is given. It is also guaranteed that the distances between any two towns is no more than 200.

func Day10

func Day10(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day10 solves the tenth day puzzle "Elves Look, Elves Say".

Input

A single line containing the "seed". For example:

3113322113

It is guaranteed that the input represents an integer.

func Day11

func Day11(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day11 solves the eleventh day puzzle "Corporate Policy".

Input

A single line containing the password, as described in the puzzle: eight lowercase letters. For example:

hepxcrrq

func Day12

func Day12(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day12 solves the twelfth day puzzle "JSAbacusFramework.io".

Input

A single line representing a JSON value. This line can be very long. Mine has 26,663 characters. For example:

{"d":"red","e":[1,2,3,4],"f":5}

Do note that it is not guaranteed that the input is a JSON object. It could be any JSON "value": string, number, object, array, or boolean. Do note that all numbers in the input are integers, that is, there are no floating-points.

func Day13

func Day13(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day13 solves the thirteenth day puzzle "Knights of the Dinner Table".

Input

A file describing the happiness loss or gain between two visitors in a group of eight visitors. For example:

Alice would gain 2 happiness units by sitting next to Bob.
Alice would gain 26 happiness units by sitting next to Carol.
Alice would lose 82 happiness units by sitting next to David.
Alice would lose 75 happiness units by sitting next to Eric.
Alice would gain 42 happiness units by sitting next to Frank.
Alice would gain 38 happiness units by sitting next to George.
Alice would gain 39 happiness units by sitting next to Mallory.
Bob would gain 40 happiness units by sitting next to Alice.
Bob would lose 61 happiness units by sitting next to Carol.
Bob would lose 15 happiness units by sitting next to David.
(this line continues)

If the happiness between one person and another is not provided it is assumed that the former would gain zero happiness units by sitting next to the latter.

It is guaranteed that the gain or loss of happiness between any two people is no more than 100.

func Day14

func Day14(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day14 solves the fourteenth day puzzle "Reindeer Olympics".

Input

A file containing nine lines, each of which describes the flying speed, flying time, and resting time for a particular reindeer. For example:

Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds.
Rudolph can fly 3 km/s for 15 seconds, but then must rest for 28 seconds.
Donner can fly 19 km/s for 9 seconds, but then must rest for 164 seconds.

It is guaranteed that the numbers are non-negative integers, each no more than 200.

func Day16

func Day16(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day16 solves the sixteenth day puzzle "Aunt Sue".

Input

A file containing 500 lines, each of which describes an Aunt Sue of a certain number, as well as three things that the person knows about a particular Sue. For example:

Sue 436: samoyeds: 3, trees: 2, cars: 6
Sue 437: children: 9, akitas: 0, pomeranians: 3
Sue 438: perfumes: 10, akitas: 2, cars: 7
Sue 439: perfumes: 10, samoyeds: 6, akitas: 10
Sue 440: vizslas: 10, trees: 2, akitas: 8

It is guaranteed that the keys will be three of the following: "children", "cats", "samoyeds", "pomerians", "akitas", "vizslas", "goldfish", "trees", "cars", and "perfumes", and that the values are non-negative integers no more than 10.

func Day17

func Day17(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day17 solves the seventeenth day puzzle "No Such Thing as Too Much".

Input

A file containing 20 lines each of which describes a container and how much it contains. For example:

50
44
11
49
42

There are no guarantees that the list in the input containers have been sorted. All containers should be non-negative integers no more than 150.

func Day20

func Day20(scanner *bufio.Scanner) (answer1, answer2 string, err error)

Day20 solves the twentieth day puzzle "Infinite Elves and Infinite Houses".

Input

A single line describing a number of presents. For example:

29000000

It is guaranteed that the input is a non-negative int32.

func Unimplemented

func Unimplemented(scanner *bufio.Scanner) (string, string, error)

Unimplemented function returns an error simply stating unimplemented.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL