Documentation ¶
Overview ¶
Package aoc2015 implements the solutions for Advent of Code 2015.
Index ¶
- Variables
- func Day01(input string) (answer1, answer2 string, err error)
- func Day02(input string) (answer1, answer2 string, err error)
- func Day03(input string) (answer1, answer2 string, err error)
- func Day04(input string) (answer1, answer2 string, err error)
- func Day04ST(input string) (answer1, answer2 string, err error)
- func Day05(input string) (answer1, answer2 string, err error)
- func Day06(input string) (answer1, answer2 string, err error)
- func Day07(input string) (answer1, answer2 string, err error)
- func Day08(input string) (answer1, answer2 string, err error)
- func Day09(input string) (answer1, answer2 string, err error)
- func Day10(input string) (answer1, answer2 string, err error)
- func Day11(input string) (answer1, answer2 string, err error)
- func Day12(input string) (answer1, answer2 string, err error)
- func Day13(input string) (answer1, answer2 string, err error)
- func Day14(input string) (answer1, answer2 string, err error)
- func Day16(input string) (answer1, answer2 string, err error)
- func Day17(input string) (answer1, answer2 string, err error)
- func Day20(input string) (answer1, answer2 string, err error)
- func Unimplemented(string) (string, string, error)
Constants ¶
This section is empty.
Variables ¶
var AllSolutions = []func(string) (string, string, error){ Day01, Day02, Day03, Day04, Day05, Day06, Day07, Day08, Day09, Day10, Day11, Day12, Day13, Day14, Unimplemented, Day16, Day17, Unimplemented, Unimplemented, Day20, Unimplemented, Unimplemented, Unimplemented, Unimplemented, Unimplemented, }
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Day04ST solves the fourth day puzzle "The Ideal Stocking Stuffer" but is a single-threaded solution.
func Day05 ¶
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 Day06 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.