diff --git a/.gitignore b/.gitignore index 1e6192a..cb560d5 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,29 @@ _testmain.go *.test *.prof -othertests +# Remove binaries +day01/day01 +day02/day02 +day03/day03 +day04/day04 +day05/day05 +day06/day06 +day07/day07 +day08/day08 +day09/day09 +day10/day10 +day11/day11 +day12/day12 +day13/day13 +day14/day14 +day15/day15 +day16/day16 +day17/day17 +day18/day18 +day19/day19 +day20/day20 +day21/day21 +day22/day22 +day23/day23 +day24/day24 +day25/day25 diff --git a/2015/day01/input b/2015/day01/input new file mode 100644 index 0000000..71a7803 --- /dev/null +++ b/2015/day01/input @@ -0,0 +1 @@ +()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()( \ No newline at end of file diff --git a/2015/day01/main.go b/2015/day01/main.go new file mode 100644 index 0000000..4b2573b --- /dev/null +++ b/2015/day01/main.go @@ -0,0 +1,70 @@ +package main + +import ( + "fmt" + "io" + "log" + "os" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + + var total int + var wentToBasement bool + var procIdx int + for _, k := range input { + for i := range k { + procIdx++ + if k[i] == '(' { + total++ + } else if k[i] == ')' { + total-- + } + if total < 0 && !wentToBasement { + wentToBasement = true + fmt.Printf("Went to basement at direction #%d\n", procIdx) + } + } + } + fmt.Printf("Santa should go to floor %d\n", total) + + fmt.Println("\nBen's Solution:") + bens() +} + +func bens() { + file, err := os.Open("./input") + floor := 0 + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + defer file.Close() + for { + data := make([]byte, 1) + _, err := file.Read(data) + if err != nil { + break + } + if data[0] == '(' { + floor = floor + 1 + } else { + floor = floor - 1 + } + + } + fmt.Printf("Floor: %d\n", floor) +} \ No newline at end of file diff --git a/2015/day01/problem b/2015/day01/problem new file mode 100644 index 0000000..2b1d5b5 --- /dev/null +++ b/2015/day01/problem @@ -0,0 +1,81 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 1: Not Quite Lisp --- + + Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by + stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December + 25th. + + Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in + the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle + grants one star. Good luck! + + Here's an easy puzzle to warm you up. + + Santa is trying to deliver presents in a large apartment building, but he can't find the right + floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) + and then follows the instructions one character at a time. + + An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means + he should go down one floor. + + The apartment building is very tall, and the basement is very deep; he will never find the top + or bottom floors. + + For example: + + • (()) and ()() both result in floor 0. + • ((( and (()(()( both result in floor 3. + • ))((((( also results in floor 3. + • ()) and ))( both result in floor -1 (the first basement level). + • ))) and )())()) both result in floor -3. + + To what floor do the instructions take Santa? + + Your puzzle answer was 138. + +--- Part Two --- + + Now, given the same instructions, find the position of the first character that causes him to + enter the basement (floor -1). The first character in the instructions has position 1, the + second character has position 2, and so on. + + For example: + + • ) causes him to enter the basement at character position 1. + • ()()) causes him to enter the basement at character position 5. + + What is the position of the character that causes Santa to first enter the basement? + + Your puzzle answer was 1771. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/1/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Not+Quite+Lisp%22+%2D+Day+1+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1&title=I%27ve+completed+%22Not+Quite+Lisp%22+%2D+Day+1+%2D+Advent+of+Code diff --git a/2015/day02/input b/2015/day02/input new file mode 100644 index 0000000..74fefbf --- /dev/null +++ b/2015/day02/input @@ -0,0 +1,1000 @@ +3x11x24 +13x5x19 +1x9x27 +24x8x21 +6x8x17 +19x18x22 +10x9x12 +12x2x5 +26x6x11 +9x23x15 +12x8x17 +13x29x10 +28x18x6 +22x28x26 +1x5x11 +29x26x12 +8x28x29 +27x4x21 +12x7x16 +7x4x23 +15x24x8 +15x14x2 +11x6x29 +28x19x9 +10x3x1 +5x20x13 +10x25x1 +22x17x7 +16x29x3 +18x22x8 +18x11x19 +21x24x20 +4x7x17 +22x27x12 +1x26x6 +5x27x24 +29x21x3 +25x30x2 +21x26x2 +10x24x27 +10x16x28 +18x16x23 +6x5x26 +19x12x20 +6x24x25 +11x20x7 +4x8x5 +2x13x11 +11x17x1 +13x24x6 +22x29x16 +4x24x20 +10x25x10 +12x29x23 +23x27x12 +11x21x9 +13x2x6 +15x30x2 +8x26x24 +24x7x30 +22x22x8 +29x27x8 +28x23x27 +13x16x14 +9x28x20 +21x4x30 +21x20x20 +11x17x30 +9x14x22 +20x2x6 +10x11x14 +1x8x23 +23x19x19 +26x10x13 +21x12x12 +25x7x24 +1x28x17 +20x23x9 +2x24x27 +20x24x29 +1x3x10 +5x20x14 +25x21x3 +15x5x22 +14x17x19 +27x3x18 +29x23x19 +14x21x19 +20x8x3 +22x27x12 +24x15x18 +9x10x19 +29x25x28 +14x22x6 +4x19x28 +4x24x14 +17x19x17 +7x19x29 +28x8x26 +7x20x16 +11x26x29 +2x18x3 +12x7x18 +11x15x21 +24x7x26 +2x22x23 +2x30x5 +1x19x8 +15x29x10 +15x26x22 +20x16x14 +25x29x22 +3x13x19 +1x12x30 +3x15x27 +19x9x11 +30x8x21 +26x12x20 +11x17x19 +17x25x1 +19x24x12 +30x6x20 +11x19x18 +18x15x29 +18x8x9 +25x15x5 +15x6x26 +13x27x19 +23x24x12 +3x15x28 +17x10x10 +15x4x7 +15x27x7 +21x8x11 +9x18x2 +7x20x20 +17x23x12 +2x19x1 +7x26x26 +13x23x8 +10x3x12 +11x1x9 +1x11x19 +25x14x26 +16x10x15 +7x6x11 +8x1x27 +20x28x17 +3x25x9 +30x7x5 +17x17x4 +23x25x27 +23x8x5 +13x11x1 +15x10x21 +22x16x1 +12x15x28 +27x18x26 +25x18x5 +21x3x27 +15x25x5 +29x27x19 +11x10x12 +22x16x21 +11x8x18 +6x10x23 +21x21x2 +13x27x28 +2x5x20 +23x16x20 +1x21x7 +22x2x13 +11x10x4 +7x3x4 +19x2x5 +21x11x1 +7x27x26 +12x4x23 +12x3x15 +25x7x4 +20x7x15 +16x5x11 +1x18x26 +11x27x10 +17x6x24 +19x13x16 +6x3x11 +4x19x18 +16x15x15 +1x11x17 +19x11x29 +18x19x1 +1x25x7 +8x22x14 +15x6x19 +5x30x18 +30x24x22 +11x16x2 +21x29x19 +20x29x11 +27x1x18 +20x5x30 +12x4x28 +3x9x30 +26x20x15 +18x25x18 +20x28x28 +21x5x3 +20x21x25 +19x27x22 +8x27x9 +1x5x15 +30x6x19 +16x5x15 +18x30x21 +4x15x8 +9x3x28 +18x15x27 +25x11x6 +17x22x15 +18x12x18 +14x30x30 +1x7x23 +27x21x12 +15x7x18 +16x17x24 +11x12x19 +18x15x21 +6x18x15 +2x21x4 +12x9x14 +19x7x25 +22x3x1 +29x19x7 +30x25x7 +6x27x27 +5x13x9 +21x4x18 +13x1x16 +11x21x25 +27x20x27 +14x25x9 +23x11x15 +22x10x26 +15x16x4 +14x16x21 +1x1x24 +17x27x3 +25x28x16 +12x2x29 +9x19x28 +12x7x17 +6x9x19 +15x14x24 +25x21x23 +26x27x25 +7x18x13 +15x10x6 +22x28x2 +15x2x14 +3x24x18 +30x22x7 +18x27x17 +29x18x7 +20x2x4 +4x20x26 +23x30x15 +5x7x3 +4x24x12 +24x30x20 +26x18x17 +6x28x3 +29x19x29 +14x10x4 +15x5x23 +12x25x4 +7x15x19 +26x21x19 +18x2x23 +19x20x3 +3x13x9 +29x21x24 +26x13x29 +30x27x4 +20x10x29 +21x18x8 +7x26x10 +29x16x21 +22x5x11 +17x15x2 +7x29x5 +6x18x15 +23x6x14 +10x30x14 +26x6x16 +24x13x25 +17x29x20 +4x27x19 +28x12x11 +23x20x3 +22x6x20 +29x9x19 +10x16x22 +30x26x4 +29x26x11 +2x11x15 +1x3x30 +30x30x29 +9x1x3 +30x13x16 +20x4x5 +23x28x11 +24x27x1 +4x25x10 +9x3x6 +14x4x15 +4x5x25 +27x14x13 +20x30x3 +28x15x25 +5x19x2 +10x24x29 +29x30x18 +30x1x25 +7x7x15 +1x13x16 +23x18x4 +1x28x8 +24x11x8 +22x26x19 +30x30x14 +2x4x13 +27x20x26 +16x20x17 +11x12x13 +28x2x17 +15x26x13 +29x15x25 +30x27x9 +2x6x25 +10x26x19 +16x8x23 +12x17x18 +26x14x22 +13x17x4 +27x27x29 +17x13x22 +9x8x3 +25x15x20 +14x13x16 +8x7x13 +12x4x21 +27x16x15 +6x14x5 +28x29x17 +23x17x25 +10x27x28 +1x28x21 +18x2x30 +25x30x16 +25x21x7 +2x3x4 +9x6x13 +19x6x10 +28x17x8 +13x24x28 +24x12x7 +5x19x5 +18x10x27 +16x1x6 +12x14x30 +1x2x28 +23x21x2 +13x3x23 +9x22x10 +10x17x2 +24x20x11 +30x6x14 +28x1x16 +24x20x1 +28x7x7 +1x24x21 +14x9x7 +22x8x15 +20x1x21 +6x3x7 +7x26x14 +5x7x28 +5x4x4 +15x7x28 +30x16x23 +7x26x2 +1x2x30 +24x28x20 +5x17x28 +4x15x20 +15x26x2 +1x3x23 +22x30x24 +9x20x16 +7x15x2 +6x21x18 +21x21x29 +29x10x10 +4x3x23 +23x2x18 +29x24x14 +29x29x16 +22x28x24 +21x18x24 +16x21x6 +3x9x22 +9x18x4 +22x9x9 +12x9x13 +18x21x14 +7x8x29 +28x28x14 +1x6x24 +11x11x3 +8x28x6 +11x16x10 +9x16x16 +6x6x19 +21x5x12 +15x17x12 +3x6x29 +19x1x26 +10x30x25 +24x26x21 +1x10x18 +6x1x16 +4x17x27 +17x11x27 +15x15x21 +14x23x1 +8x9x30 +22x22x25 +20x27x22 +12x7x9 +9x26x19 +26x25x12 +8x8x16 +28x15x10 +29x18x2 +25x22x6 +4x6x15 +12x18x4 +10x3x20 +17x28x17 +14x25x13 +14x10x3 +14x5x10 +7x7x22 +21x2x14 +1x21x5 +27x29x1 +6x20x4 +7x19x23 +28x19x27 +3x9x18 +13x17x17 +18x8x15 +26x23x17 +10x10x13 +11x5x21 +25x15x29 +6x23x24 +10x7x2 +19x10x30 +4x3x23 +22x12x6 +11x17x16 +6x8x12 +18x20x11 +6x2x2 +17x4x11 +20x23x22 +29x23x24 +25x11x21 +22x11x15 +29x3x9 +13x30x5 +17x10x12 +10x30x8 +21x16x17 +1x5x26 +22x15x16 +27x7x11 +16x8x18 +29x9x7 +25x4x17 +10x21x25 +2x19x21 +29x11x16 +18x26x21 +2x8x20 +17x29x27 +25x27x4 +14x3x14 +25x29x29 +26x18x11 +8x24x28 +7x30x24 +12x30x22 +29x20x6 +3x17x1 +6x15x14 +6x22x20 +13x26x26 +12x2x1 +7x14x12 +15x16x11 +3x21x4 +30x17x29 +9x18x27 +11x28x16 +22x3x25 +18x15x15 +2x30x12 +3x27x22 +10x8x8 +26x16x14 +15x2x29 +12x10x7 +21x20x15 +2x15x25 +4x14x13 +3x15x13 +29x8x3 +7x7x28 +15x10x24 +23x15x5 +5x7x14 +24x1x22 +1x11x13 +26x4x19 +19x16x26 +5x25x5 +17x25x14 +23x7x14 +24x6x17 +5x13x12 +20x20x5 +22x29x17 +11x17x29 +25x6x4 +29x8x16 +28x22x24 +24x23x17 +16x17x4 +17x8x25 +22x9x13 +24x4x8 +18x10x20 +21x23x21 +13x14x12 +23x26x4 +4x10x29 +2x18x18 +19x5x21 +2x27x23 +6x29x30 +21x9x20 +6x5x16 +25x10x27 +5x29x21 +24x14x19 +19x11x8 +2x28x6 +19x25x6 +27x1x11 +6x8x29 +18x25x30 +4x27x26 +8x12x1 +7x17x25 +7x14x27 +12x9x5 +14x29x13 +18x17x5 +23x1x3 +28x5x13 +3x2x26 +3x7x11 +1x8x7 +12x5x4 +2x30x21 +16x30x11 +3x26x4 +16x9x4 +11x9x22 +23x5x6 +13x20x3 +4x3x2 +14x10x29 +11x8x12 +26x15x16 +7x17x29 +18x19x18 +8x28x4 +22x6x13 +9x23x7 +11x23x20 +13x11x26 +15x30x13 +1x5x8 +5x10x24 +22x25x17 +27x20x25 +30x10x21 +16x28x24 +20x12x8 +17x25x1 +30x14x9 +14x18x6 +8x28x29 +12x18x29 +9x7x18 +6x12x25 +20x13x24 +22x3x12 +5x23x22 +8x10x17 +7x23x5 +10x26x27 +14x26x19 +10x18x24 +8x4x4 +16x15x11 +3x14x9 +18x5x30 +29x12x26 +16x13x12 +15x10x7 +18x5x26 +14x1x6 +10x8x29 +3x4x9 +19x4x23 +28x17x23 +30x7x17 +19x5x9 +26x29x28 +22x13x17 +28x2x1 +20x30x8 +15x13x21 +25x23x19 +27x23x1 +4x6x23 +29x29x24 +5x18x7 +4x6x30 +17x15x2 +27x4x2 +25x24x14 +28x8x30 +24x29x5 +14x30x14 +10x18x19 +15x26x22 +24x19x21 +29x23x27 +21x10x16 +7x4x29 +14x21x3 +21x4x28 +17x16x15 +24x7x13 +21x24x15 +25x11x16 +10x26x13 +23x20x14 +20x29x27 +14x24x14 +14x23x12 +18x6x5 +3x18x9 +8x18x19 +20x26x15 +16x14x13 +30x16x3 +17x13x4 +15x19x30 +20x3x8 +13x4x5 +12x10x15 +8x23x26 +16x8x15 +22x8x11 +12x11x18 +28x3x30 +15x8x4 +13x22x13 +21x26x21 +29x1x15 +28x9x5 +27x3x26 +22x19x30 +4x11x22 +21x27x20 +22x26x7 +19x28x20 +24x23x16 +26x12x9 +13x22x9 +5x6x23 +20x7x2 +18x26x30 +3x6x28 +24x18x13 +28x19x16 +25x21x25 +25x19x23 +22x29x10 +29x19x30 +4x7x27 +5x12x28 +8x26x6 +14x14x25 +17x17x2 +5x27x11 +8x2x2 +3x20x24 +26x10x9 +22x28x27 +18x15x20 +12x11x1 +5x14x30 +7x3x16 +2x16x16 +18x20x15 +13x14x29 +1x17x12 +13x5x23 +19x4x10 +25x19x11 +15x17x14 +1x28x27 +11x9x28 +9x10x18 +30x11x22 +21x21x20 +2x1x5 +2x25x1 +7x3x4 +22x15x29 +21x28x15 +12x12x4 +21x30x6 +15x10x7 +10x14x6 +21x26x18 +14x25x6 +9x7x11 +22x3x1 +1x16x27 +1x14x23 +2x13x8 +14x19x11 +21x26x1 +4x28x13 +12x16x20 +21x13x9 +3x4x13 +14x9x8 +21x21x12 +27x10x17 +6x20x6 +28x23x23 +2x28x12 +8x10x10 +3x9x2 +20x3x29 +19x4x16 +29x24x9 +26x20x8 +15x28x26 +18x17x10 +7x22x10 +20x15x9 +6x10x8 +7x26x21 +8x8x16 +15x6x29 +22x30x11 +18x25x8 +6x21x20 +7x23x25 +8x25x26 +11x25x27 +22x18x23 +3x2x14 +16x16x1 +15x13x11 +3x9x25 +29x25x24 +9x15x1 +12x4x1 +23x30x20 +3x1x23 +6x10x29 +28x13x24 +4x19x17 +6x6x25 +27x29x17 +12x13x2 +10x7x13 +14x15x8 +22x2x3 +27x17x19 +23x10x16 +5x9x25 +9x25x14 +11x18x6 +18x10x12 +9x4x15 +7x16x14 +17x24x10 +11x4x6 +12x9x17 +22x18x12 +6x24x24 +6x22x23 +5x17x30 +6x9x5 +17x20x10 +6x8x12 +14x17x13 +29x10x17 +22x4x5 +10x19x30 +22x29x11 +10x12x29 +21x22x26 +16x6x25 +1x26x24 +30x17x16 +27x28x5 +30x13x22 +7x26x12 +11x24x30 +1x17x25 +22x1x3 +29x24x6 +4x8x24 +13x9x20 +8x12x9 +21x25x4 +23x23x28 +5x2x19 +29x3x15 +22x1x14 +3x23x30 +8x25x3 +15x8x14 +30x14x6 +23x27x24 +19x1x2 +10x9x13 +13x8x7 +8x13x22 +5x15x20 +17x14x8 +5x11x20 +5x10x27 +24x17x19 +21x2x3 +15x30x26 +21x19x15 +2x7x23 +13x17x25 +30x15x19 +26x4x10 +2x25x8 +9x9x10 +2x25x8 +19x21x30 +17x26x12 +7x5x10 +2x22x14 +10x17x30 +1x8x5 +23x2x25 +22x29x8 +13x26x1 +26x3x30 +25x17x8 +25x18x26 +26x19x15 +8x28x10 +12x16x29 +30x6x29 +28x19x4 +27x26x18 +15x23x17 +5x21x30 +8x11x13 +2x26x7 +19x9x24 +3x22x23 +6x7x18 +4x26x30 +13x25x20 +17x3x15 +8x20x18 +23x18x23 +28x23x9 +16x3x4 +1x29x14 +20x26x22 +3x2x22 +23x8x17 +19x5x17 +21x18x20 +17x21x8 +30x28x1 +29x19x23 +12x12x11 +24x18x7 +21x18x14 +14x26x25 +9x11x3 +10x7x15 +27x6x28 +14x26x4 +28x4x1 +22x25x29 +6x26x6 +1x3x13 +26x22x12 +6x21x26 +23x4x27 +26x13x24 +5x24x28 +22x16x7 +3x27x24 +19x28x2 +11x13x9 +29x16x22 +30x10x24 +14x14x22 +22x23x16 +14x8x3 +20x5x14 +28x6x13 +3x15x25 +4x12x22 +15x12x25 +10x11x24 +7x7x6 +8x11x9 +21x10x29 +23x28x30 +8x29x26 +16x27x11 +1x10x2 +24x20x16 +7x12x28 +28x8x20 +14x10x30 +1x19x6 +4x12x20 +18x2x7 +24x18x17 +16x11x10 +1x12x22 +30x16x28 +18x12x11 +28x9x8 +23x6x17 +10x3x11 +5x12x8 +22x2x23 +9x19x14 +15x28x13 +27x20x23 +19x16x12 +19x30x15 +8x17x4 +10x22x18 +13x22x4 +3x12x19 +22x16x23 +11x8x19 +8x11x6 +7x14x7 +29x17x29 +21x8x12 +21x9x11 +20x1x27 +1x22x11 +5x28x4 +26x7x26 +30x12x18 +29x11x20 +3x12x15 +24x25x17 +14x6x11 \ No newline at end of file diff --git a/2015/day02/main.go b/2015/day02/main.go new file mode 100644 index 0000000..e80ae69 --- /dev/null +++ b/2015/day02/main.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "io" + "log" + "strconv" + "strings" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + var totalPaper, totalRibbon int + for _, k := range input { + l, w, h := parseInputString(k) + totalPaper += calcPaperForPresent(l, w, h) + totalRibbon += calcRibbonForPresent(l, w, h) + } + fmt.Printf("The elves need %d sq ft of wrapping paper\n", totalPaper) + fmt.Printf("and %d ft of ribbon.\n", totalRibbon) +} + +func parseInputString(inp string) (int, int, int) { + dim := strings.Split(inp, "x") + if len(dim) == 3 { + pt1, _ := strconv.Atoi(dim[0]) + pt2, _ := strconv.Atoi(dim[1]) + pt3, _ := strconv.Atoi(dim[2]) + return pt1, pt2, pt3 + } + return 0, 0, 0 +} + +func calcPaperForPresent(l, w, h int) int { + pt1 := l * w + pt2 := w * h + pt3 := h * l + pt4 := pt3 + if pt1 < pt2 && pt1 < pt3 { + pt4 = pt1 + } else if pt2 < pt3 { + pt4 = pt2 + } + return pt1*2 + pt2*2 + pt3*2 + pt4 +} + +func calcRibbonForPresent(l, w, h int) int { + var low1, low2 int + low2 = h + if l < w { + low1 = l + if w < h { + low2 = w + } + } else { + low1 = w + if l < h { + low2 = l + } + } + return low1*2 + low2*2 + (l * w * h) +} \ No newline at end of file diff --git a/2015/day02/problem b/2015/day02/problem new file mode 100644 index 0000000..271d078 --- /dev/null +++ b/2015/day02/problem @@ -0,0 +1,77 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 2: I Was Told There Would Be No Math --- + + The elves are running low on wrapping paper, and so they need to submit an order for more. They + have a list of the dimensions (length l, width w, and height h) of each present, and only want + to order exactly as much as they need. + + Fortunately, every present is a box (a perfect right rectangular prism), which makes + calculating the required wrapping paper for each gift a little easier: find the surface area of + the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each + present: the area of the smallest side. + + For example: + + • A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping + paper plus 6 square feet of slack, for a total of 58 square feet. + • A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping + paper plus 1 square foot of slack, for a total of 43 square feet. + + All numbers in the elves' list are in feet. How many total square feet of wrapping paper should + they order? + + Your puzzle answer was 1588178. + +--- Part Two --- + + The elves are also running low on ribbon. Ribbon is all the same width, so they only have to + worry about the length they need to order, which they would again like to be exact. + + The ribbon required to wrap a present is the shortest distance around its sides, or the + smallest perimeter of any one face. Each present also requires a bow made out of ribbon as + well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of + the present. Don't ask how they tie the bow, though; they'll never tell. + + For example: + + • A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present + plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet. + • A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present + plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 feet. + + How many total feet of ribbon should they order? + + Your puzzle answer was 3783758. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid + . http://adventofcode.com/ + . http://adventofcode.com/day/2/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22I+Was+Told+There+Would+Be+No+Math%22+%2D+Day+2+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2&title=I%27ve+completed+%22I+Was+Told+There+Would+Be+No+Math%22+%2D+Day+2+%2D+Advent+of+Code diff --git a/2015/day03/input b/2015/day03/input new file mode 100644 index 0000000..a5954e7 --- /dev/null +++ b/2015/day03/input @@ -0,0 +1 @@ +v>vvv>v<<<^^^^^<<^^>v^>^>^>^>^>^<<^><<<^vvvv>^>^><^v^><^<>^^>^vvv^>^>^^<>><>^>vvv>>^vv>^<><>^^>^>><<^><><>^<^>>vvv>v>>>v<<^<><^v>^^v^^^<^v^^>>><^>^>v<>^<>>^>^^v^>>><>v^v<>>^>^<>v^>^<>^v^^^v^^>>vv<<^^><^^>^^<^>>^^^^^v^vv<>>v^v<^v^^<><^<^vv^><>><><>v>vvv^vv^^<<><<<^v^>vvv^<^>vvvv^>^>>^v^v>vv^<>><^^^>^>>v>^>v^<>v><^<^^^vv<^^<>v^v^vv<>>>>v^v<>><^^v>vv^^>v^v>v>v>>vv>^^>^v><<^<vv^^^v>v^^^>><^^>v>^^v>>v^^^<^^v>^v>><^<^<>>v<<^^vv>^^^v<^<^^vv^>>v^>><<<>^vv^<^<>v^^<<^><>>^^^<^vv<^^^>><^^v>^^v^^^^<^v<^<<<<^v^<^^<>^^>^><<>>^v><>><^<^^^>>vv>^>^^^^^v^vvv><><^<^>v>v^v^>^><><^<^><>v<><>^v^^v>^<<<>^v^>^<v^<>>^vv>v>>>^<^>>>>>v>>^v>v><>>vvv<^^><<^>^>v<^vvvv<^^^v^^^>v^v<>v<^^v>>><>v>v>>^^<^^v><<<<<^vv<^<>^>>>^v>^v>vv>^v<>v>v<^>>v>>^>^><^^v<><><^^>^^^^>vv^v^v>^v^^v^^v>><^v>>vv<>vvvv<>>^v^>^>>v^v^<<>>^v<^^vv^><>v>^>v><<<<<<<^>^^v^<<^^>>vvv^<><>><>^^v<<^^v<^^>v^>>>v^v>v^><>v<<>v>^^v><<<<><^v^v>>^<>^<<>^>v<<>><^<<<<^v>^<^v>v>vv^>v<^<<>v^v>><v>v>>v^vvv^^>>>v^<^<<^^<<<>v^<v<^^<>^>v>>v<>^>^^>>^v<<>v^^^>>>^vv<^v^>v>^><>v^^<>^^v^^vv^<^>^<<>><<^>^v>>><<<<><<^v>v^<^><^<>>v^>^^^<>>v<>>^>>v^><<>vvv><^>>v><>v>>^>v><<><<>^<>^^^vv>v^^>>^>^<^vv^>v^>^><^<^><><v<^^v^^<<<<^><^^<^><>>^v<<^<<^vv>v>>v<^<^vv>>v^v<>^>v<>^v<<>^^v>>>v^>^v^v>^^^v><^>vvv^<<<>v<>v>^>vv^<^^v^><^^^^^v<^>>vv^v^>^^<>>><^v^<v>^v>^^v<>>vv>>^v>>^<<<<^><<<><^^>>v<>^vvvv>v^^^>^^^>^<^^vv<^v^v<v^^<>^>^<^v>vvv><<^><><^^v<<><^^><>^v>^<><<^<^^<<>vv<>^^<<^>><<<>>vvv>^>v^^v^><<^>v>^>^<^<<>v<^>vv^v^v<>vv<vv<^>v^<>^vv^v^>>>v^v><^<><<>vv^>vvv^>v>>><^^vvv<^<^>>^^>^^vv>>><^v<>^v^<<>v^^^^>>^<^>^v<^^^^v>^>>v>^>^>>>v^<<^>^<<^^<>v<^v<^<>v^v>^^v^vv>vvv>v^<^>>vvvv<>>^^<>v^<><>v<^<>v<>^>v<>vv>v<^^>v>><>>^<^^<>>^>^>vvv^v>>^>^>v><><<>v<>^v<^vv^^^<>^^<<^^^v<>>v^>vvvv>^^v^>^>^<<><^^^^<<>^<>vv^<><^>^^<>v^<>>>v><>vvvvv>v>v^^>^<vv>>v<<^<>^^^v^<><>>^<<>>><>v>^>^^^^vv^^<<><^^<v>vv<<<^<v<>>^<^>^>>v>><^^<>><<<><<><^<^v<^^v<<>><<<<^>v^>v^v^<<>>v<><^<>><>>^><>v^v>v<<>v<>v^^><<>>>v<<>>>>^>v>>>>vv>v>^<^^^<>v^<^^v^vvv^>vv>^^<<>vvv<<^^<^>^>>v>v<<<<<>^^vv^>>v>^<^^v>>v>^v<><>^<^>v>v<<<^^^v>^<<<>vvv^v^^>^>>^>v>v<>^^><>>v>^>v<<<^^^v^><><^<^<>>^v>vv<^v<<^vv>v^<v>v>^v^>^v<<^v^vv>v^<<>>v<>>vvv^^vv^^v><^>v^vv<^^<<>v<><^><>^<><vv<>^vv>v><^^v<>><^v^v><><>>vv<>>>><<^>>><^^^vvv<<><>>>v<<<<<>v^^<<^vv^>vv>^<>^v^^<>^^^vv>v^^v>^v>^<>v^^^>v^^v<^>v^v^<>v>v>v<^^vv^v<^^^^vv<<><<^>>^^<v^>>^^^><^^>^v^v>^<^>>^v<>^<^>v>^>^v^<^^^<^vv<^^>>v^>^v^>>>>^v>^^<<^<^^v^<<<>>><>^<>>>v<<><<^^<^^>v^>^>v^v<><^^v>^<^v^v>>>^^<^^vv<<^><><^<>v>>>vv>><^^^v^^^v<^^v>v<>>^^<><>v>^^>>>><>v>^v>^vv^v>^>^^^><>^<<>>><<<><>^^<<v^>v>v^^^>^>^v<<>v>vv>><<^^^>>^><^>v<^<^v>><^^>v<><>^><<><>v^>v<><^^>><>^<^^v<^<><<<^^<><>>>^>v^<><^<<^vv<^v^v^v<>v^^v>v^<^>^vv^>>><<>v^vv^<>^v^><v^<><>>v^v^><>v^vvv^^^<<^<>v^v>^^><>v>>v^<>^>v>^>><<>v^v><^v>v>>><^<^^>vv<^>^<^>^^v><><^<<^^vvv^v>^>^<>>vv>v^^v^^vv<^^>><^v>v^<vvv<>>^v><<>^v<<<>^><^vv><<^^v<^vv<>^v>>>><<<<^^<^v>^<^^<^<^^>>^^v>^^^^v^^^<<>^^vv<><^<<><>^>v<>>v^^^>^v^^v^v>>>>>^v>^>^^v>><^^^v<<^^>^<^<^><^<<>v>v>^v<><^>vv^vv><^><>^><<^^>v>v>^^^<>v>^v^^>vv^vv<^^>><>^>^<>v>><>^v<v>^><^^^v^<<^v^>v^>vv>v^<>v><^v>v<>^v<>^v>^^<>vvv^>^<><^>><^<>^v<<^v^><<^<^v>^vv^v>v<^^vv<><>vv^>v<<>v>v>^^>>><<<^>^vv>>^^^>v<^vv<>v<<>>>^<^^^^>v<^^<>v>vvv^>v>v<^>^v^<>v>>vvv>^^><^vvv>><>>>^<<^>>v^^>>^><>v<^^v^<<>^<>>><^v^v>>>^vvvv^<><<>v>^v^v>v><^<<^>^^>v<^v^<^>v>^<v^<>v^<>vv^<>^>^>v^>^vv<>^^<<>>v<>^v<><><<v>v^>vv^><<<^v<><>^^v^^v^^^>^<>>>>^><>>v>>v<<>v<<<<<<<^v<<^^^v<^v<>v^^<<<^<>>v^vv^<^^<^^<<^>vv><^<^^v<<<^><^v<^><>v^v^^>>><<^<<^<>>^>>^<<<>>v>^v>><>v>>v>><>v>><^^>^^vv<^^<^>vv><<^>><<>^vvv><^v^>vvv^>>^<><^>^<<>>v^v>v<<>^>>^>v<^^<^<<>^^v^^v>v<>^<^^<v^^vvv^^v>^vv^<>v<^v^>^vv<v^<<^>^><^^<^^<^>vv^<>^<>^>^^<^v><<<^>vv^vv>v^v<>^^v^<^^^vvv^>v^<><>v>vv<^v^>>^v<^^vv>vv>^>><<<<>^><>>v<>>v>^v<^vv>^^>^<^<>v^v<^^v<^^>^^<>^^^^>^vv<^>><^>vv^>v^>^vv>^>v^^<>>^v<>>v<^>^v>vv^>^>>>vvv>vv>^><^v<<<>^^v>v^v<^^^v^^>^><<^^>^><^^^^^^^<^v<^>>vv>>^v^vv<>><>^>>>^^^^^><^<<^v<>vv^>>v<^vv<^v<>v<>^v^<<>>>>v^^>^vv<<><<>v^v<^<^>>^^><^>^><<><^<><>vv>>>>^><<^^^<^v^>^>^^>^<^><^^<^^<>><>><<<>^>^^v<>^<<>vv>^>>^>^<>>vv<^^vv<>v<>^^>^v^v^v>^^^v<<<^vv^><>^>^^vv>v^<<^><>>vv^^^^^>v>>v<<<>^<><^v<^v<^>^<>^vvv>^>v><<v>vv^<^^>v^v>^<^v^<^v<<^>^<><>^^<>>^^<^v^<^<<^>v^^>v^v^^^<^v<<^v>^>>^^^^^><<>v^><>v^^<^v<^<v^^^><^^^><<<<<>^<<^<>>v<^>><^^^<>>>>vvv>v<>>>v^v^v<^<<^>^<<>v>>^>^^><^><<^v^^<^<>v^v>vv<>>>>>>v<<>>^^>v<<<>^<<^><<^v>vv>>>><><>v^<^v><^>v>>^^^v<^>>^>>v<<^<<>vvv>>^v<>>^v><<<^v^v<>^vvv^^^<>vvv^^^>>v>^>^<><<>vv>^v^>>^<v><><<>^^><>^<<>^v<<>>v^vv<<>^^v^v^v><^>v>v<^<<^<^>vv>^v<<^>^>>v^<v^^v^^>><<<>^v>><>v<>><^v>^^v<<<<^v^vv<<<<><><^<^<^v><<^^v^<<<<<^^><^^>vvv<^><>vvv^v^>^>^^^v<<^<^^>vv^vv^><^v^<<>v<^^>^vv<<>^<<><^>v^<<^<>v><><>v<<^^><^^^v>>v>^vv>^v^^<><<<<<^>^v^<^<^^>^vv<^>v^^v^<>v<>v^v>vvv><><<><>vv^^>^^^<><^>^^^>vvv><>v<>>v^>v^^vv^>v>>>><^^>^v^v>>vv<^>><<<^>><^<^>^<^>^>>v^<^<>^<^^<>^<>>><^<^<^<<^><^^>vv<>^^>v^>>v>>>v<<^vv^<><>>>^^<^v^>>^>>><<^<>^>>^v>>><^^^<<^vv><><<>^^^<>^^^>><>>>^>vv>^<^<>>^<^^>v^>vv><><>>><><<^^v<<^vvv<><><<^v>^v<>^<^^^v^>^<^><^v>v>^v<>><^^v^^^^^<>>vvvv>>>>^<<><^v>vv>>^^><<><><^^^<^<^<<^v>^^^>>>>><v^^^<>>vv^^^v<><^>v>><<><>v<^><<>>><>v>^<>>^>v^v<<<<>^vv<<>>>>>vv<><>^<^v>vv^<>><<>^<>><^>>>><<>^^>><<<^^^^^v>>^<<>>vvvv<^v^vvv<<<^><>>>>vv^<^v>v<^<>^v>>^<^^v^>>><>^^<^v>>v<<>vvvv>^><>v^<>^<<^vv<^>>^v^>^^<<<^>>^^>^<^^<^<<v^^v^^<^v<^>>><<>vv<<^><^>vv<^>>^vv>>>^>>><^<<<>>^<<>><^<<^^^>>v^^>v<<<>v>v>v^<>>>^vvv><<^^<<><^v>>>>vv^^v^v<>v>v<<<<><<>vv<><^^^<>>v>>>>^^<><^<^v^>>^^v>^<v>^^>^v^<>>v^^<^v^^<<>^^>v^^>><<<<^<^^v>^^v>v<^>v^<>vv>>^^v>v^^>vvvvv<<>vv>vvvvvv>>v>>^^^vv^^><>v^^^^v>vv>v<^v>>>>^>^>^v>^>>><<>>^vv>>>><><<^<^><^vv^v>>>>>v>^>^^v^>v<^v^<^<v<>>^vv<<>^v^v>><><<>>v^^<<>^^<>v<<^^<^^>^^>^<^><>>v<>>^^<^>><<>>^v^>v>v<<^^<<^>v>v^^v^^<<>^v>v>v<^^>^v<><^<<v<^<<<<^^>v^v^^><<><^^^v^^>>>vvv><>vv<>>^^v^v<<^>v^^v^>vv>^<^^<^v^^<^^v<<>>vv<^>>^><><>v>>v<>^<<>>> \ No newline at end of file diff --git a/2015/day03/main.go b/2015/day03/main.go new file mode 100644 index 0000000..e6c99fe --- /dev/null +++ b/2015/day03/main.go @@ -0,0 +1,60 @@ +package main + +import ( + "fmt" + "io" + "log" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + + santaResults := santa(input, 0, 2) + santaResults["0;0"] = 1 + roboResults := santa(input, 1, 2) + for i, k := range roboResults { + santaResults[i] += k + } + fmt.Printf("Santa delivered presents to %d houses\n", len(santaResults)) +} + +func santa(input []string, offset, numWorkers int) map[string]int { + var numDir int + houses := make(map[string]int) + var currX, currY int + for _, k := range input { + for _, r := range k { + if numDir >= offset { + if (numDir+offset)%(numWorkers) == 0 { + // We've waited, now start visiting + switch r { + case '^': + currY-- + case '>': + currX++ + case 'v': + currY++ + case '<': + currX-- + } + houseCoords := fmt.Sprintf("%d;%d", currX, currY) + houses[houseCoords]++ + } + } + numDir++ + } + } + + return houses +} \ No newline at end of file diff --git a/2015/day03/problem b/2015/day03/problem new file mode 100644 index 0000000..f456e3c --- /dev/null +++ b/2015/day03/problem @@ -0,0 +1,75 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 3: Perfectly Spherical Houses in a Vacuum --- + + Santa is delivering presents to an infinite two-dimensional grid of houses. + + He begins by delivering a present to the house at his starting location, and then an elf at the + North Pole calls him via radio and tells him where to move next. Moves are always exactly one + house to the north (^), south (v), east (>), or west (<). After each move, he delivers another + present to the house at his new location. + + However, the elf back at the north pole has had a little too much eggnog, and so his directions + are a little off, and Santa ends up visiting some houses more than once. How many houses + receive at least one present? + + For example: + + • > delivers presents to 2 houses: one at the starting location, and one to the east. + • ^>v< delivers presents to 4 houses in a square, including twice to the house at his + starting/ending location. + • ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. + + Your puzzle answer was 2572. + +--- Part Two --- + + The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, + to deliver presents with him. + + Santa and Robo-Santa start at the same location (delivering two presents to the same starting + house), then take turns moving based on instructions from the elf, who is eggnoggedly reading + from the same script as the previous year. + + This year, how many houses receive at least one present? + + For example: + + • ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south. + • ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they + started. + • ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and + Robo-Santa going the other. + + Your puzzle answer was 2631. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/3/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Perfectly+Spherical+Houses+in+a+Vacuum%22+%2D+Day+3+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3&title=I%27ve+completed+%22Perfectly+Spherical+Houses+in+a+Vacuum%22+%2D+Day+3+%2D+Advent+of+Code diff --git a/2015/day04/input b/2015/day04/input new file mode 100644 index 0000000..203cf7c --- /dev/null +++ b/2015/day04/input @@ -0,0 +1 @@ +yzbqklnj \ No newline at end of file diff --git a/2015/day04/main.go b/2015/day04/main.go new file mode 100644 index 0000000..1eb8610 --- /dev/null +++ b/2015/day04/main.go @@ -0,0 +1,48 @@ +package main + +import ( + "crypto/md5" + "fmt" + "io" + "log" + "strconv" +) + +func main() { + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + } + firstCoin := searchChunk(readInp, 0, 1000000000) + fmt.Printf("\n%s%d :: %d\n", readInp, firstCoin, firstCoin) +} + +func searchChunk(key string, start, end int) int { + // So we know it's still running + for i := start; i <= end; i++ { + coin := key + strconv.Itoa(i) + coinMd5 := fmt.Sprintf("%x", md5.Sum([]byte(coin))) + if isCoin(coinMd5, "000000") { + return i + } + } + return -1 +} + +func isCoin(s string, moneyMaker string) bool { + if len(s) < len(moneyMaker) { + return false + } + for i := 0; i < len(moneyMaker); i++ { + if s[i] != moneyMaker[i] { + return false + } + } + return true +} \ No newline at end of file diff --git a/2015/day04/problem b/2015/day04/problem new file mode 100644 index 0000000..f53aa0a --- /dev/null +++ b/2015/day04/problem @@ -0,0 +1,61 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 4: The Ideal Stocking Stuffer --- + + Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the + economically forward-thinking little girls and boys. + + To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. + The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a + number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no + leading zeroes: 1, 2, 3, ...) that produces such a hash. + + For example: + + • If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 + starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. + • If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash + starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like + 000006136ef.... + + Your puzzle answer was 282749. + +--- Part Two --- + + Now find one that starts with six zeroes. + + Your puzzle answer was 9962624. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + Your puzzle input was yzbqklnj. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Bitcoin#Mining + . https://en.wikipedia.org/wiki/Bitcoin + . https://en.wikipedia.org/wiki/MD5 + . https://en.wikipedia.org/wiki/Hexadecimal + . http://adventofcode.com/ + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22The+Ideal+Stocking+Stuffer%22+%2D+Day+4+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4&title=I%27ve+completed+%22The+Ideal+Stocking+Stuffer%22+%2D+Day+4+%2D+Advent+of+Code diff --git a/2015/day05/input b/2015/day05/input new file mode 100644 index 0000000..a9b6e77 --- /dev/null +++ b/2015/day05/input @@ -0,0 +1,1000 @@ +sszojmmrrkwuftyv +isaljhemltsdzlum +fujcyucsrxgatisb +qiqqlmcgnhzparyg +oijbmduquhfactbc +jqzuvtggpdqcekgk +zwqadogmpjmmxijf +uilzxjythsqhwndh +gtssqejjknzkkpvw +wrggegukhhatygfi +vhtcgqzerxonhsye +tedlwzdjfppbmtdx +iuvrelxiapllaxbg +feybgiimfthtplui +qxmmcnirvkzfrjwd +vfarmltinsriqxpu +oanqfyqirkraesfq +xilodxfuxphuiiii +yukhnchvjkfwcbiq +bdaibcbzeuxqplop +ivegnnpbiyxqsion +ybahkbzpditgwdgt +dmebdomwabxgtctu +ibtvimgfaeonknoh +jsqraroxudetmfyw +dqdbcwtpintfcvuz +tiyphjunlxddenpj +fgqwjgntxagidhah +nwenhxmakxqkeehg +zdoheaxqpcnlhnen +tfetfqojqcdzlpbm +qpnxkuldeiituggg +xwttlbdwxohahwar +hjkwzadmtrkegzye +koksqrqcfwcaxeof +wulwmrptktliyxeq +gyufbedqhhyqgqzj +txpunzodohikzlmj +jloqfuejfkemcrvu +amnflshcheuddqtc +pdvcsduggcogbiia +yrioavgfmeafjpcz +uyhbtmbutozzqfvq +mwhgfwsgyuwcdzik +auqylgxhmullxpaa +lgelzivplaeoivzh +uyvcepielfcmswoa +qhirixgwkkccuzlp +zoonniyosmkeejfg +iayfetpixkedyana +ictqeyzyqswdskiy +ejsgqteafvmorwxe +lhaiqrlqqwfbrqdx +ydjyboqwhfpqfydc +dwhttezyanrnbybv +edgzkqeqkyojowvr +rmjfdwsqamjqehdq +ozminkgnkwqctrxz +bztjhxpjthchhfcd +vrtioawyxkivrpiq +dpbcsznkpkaaclyy +vpoypksymdwttpvz +hhdlruwclartkyap +bqkrcbrksbzcggbo +jerbbbnxlwfvlaiw +dwkasufidwjrjfbf +kkfxtjhbnmqbmfwf +vmnfziwqxmioukmj +rqxvcultipkecdtu +fhmfdibhtjzkiqsd +hdpjbuzzbyafqrpd +emszboysjuvwwvts +msyigmwcuybfiooq +druyksfnbluvnwoh +fvgstvynnfbvxhsx +bmzalvducnqtuune +lzwkzfzttsvpllei +olmplpvjamynfyfd +padcwfkhystsvyfb +wjhbvxkwtbfqdilb +hruaqjwphonnterf +bufjobjtvxtzjpmj +oiedrjvmlbtwyyuy +sgiemafwfztwsyju +nsoqqfudrtwszyqf +vonbxquiiwxnazyl +yvnmjxtptujwqudn +rrnybqhvrcgwvrkq +taktoxzgotzxntfu +quffzywzpxyaepxa +rfvjebfiddcfgmwv +iaeozntougqwnzoh +scdqyrhoqmljhoil +bfmqticltmfhxwld +brbuktbyqlyfpsdl +oidnyhjkeqenjlhd +kujsaiqojopvrygg +vebzobmdbzvjnjtk +uunoygzqjopwgmbg +piljqxgicjzgifso +ikgptwcjzywswqnw +pujqsixoisvhdvwi +trtuxbgigogfsbbk +mplstsqclhhdyaqk +gzcwflvmstogdpvo +tfjywbkmimyyqcjd +gijutvhruqcsiznq +ibxkhjvzzxgavkha +btnxeqvznkxjsgmq +tjgofgauxaelmjoq +sokshvyhlkxerjrv +ltogbivktqmtezta +uduwytzvqvfluyuf +msuckpthtgzhdxan +fqmcglidvhvpirzr +gwztkqpcwnutvfga +bsjfgsrntdhlpqbx +xloczbqybxmiopwt +orvevzyjliomkkgu +mzjbhmfjjvaziget +tlsdxuhwdmghdyjb +atoecyjhwmznaewi +pyxpyvvipbqibiox +ajbfmpqqobfsmesj +siknbzefjblnohgd +eqfhgewbblwdfkmc +opylbscrotckkrbk +lbwxbofgjkzdxkle +ceixfjstaptdomvm +hnkrqxifjmmjktie +aqykzeuzvvetoygd +fouahjimfcisxima +prkzhutbqsyrhjzx +qqwliakathnsbzne +sayhgqtlcqqidqhj +ygduolbysehdudra +zricvxhdzznuxuce +ucvzakslykpgsixd +udirhgcttmyspgsb +yuwzppjzfsjhhdzi +gtqergjiuwookwre +xvxexbjyjkxovvwf +mlpaqhnnkqxrmwmm +ezuqbrjozwuqafhb +mcarusdthcbsonoq +weeguqeheeiigrue +pngtfugozxofaqxv +copphvbjcmfspenv +jiyahihykjjkdaya +gdqnmesvptuyrfwp +vbdscfywqmfxbohh +crtrfuxyjypzubrg +seihvevtxywxhflp +fvvpmgttnapklwou +qmqaqsajmqwhetpk +zetxvrgjmblxvakr +kpvwblrizaabmnhz +mwpvvzaaicntrkcp +clqyjiegtdsswqfm +ymrcnqgcpldgfwtm +nzyqpdenetncgnwq +cmkzevgacnmdkqro +kzfdsnamjqbeirhi +kpxrvgvvxapqlued +rzskbnfobevzrtqu +vjoahbfwtydugzap +ykbbldkoijlvicbl +mfdmroiztsgjlasb +quoigfyxwtwprmdr +ekxjqafwudgwfqjm +obtvyjkiycxfcdpb +lhoihfnbuqelthof +eydwzitgxryktddt +rxsihfybacnpoyny +bsncccxlplqgygtw +rvmlaudsifnzhcqh +huxwsyjyebckcsnn +gtuqzyihwhqvjtes +zreeyomtngvztveq +nwddzjingsarhkxb +nuqxqtctpoldrlsh +wkvnrwqgjooovhpf +kwgueyiyffudtbyg +tpkzapnjxefqnmew +ludwccvkihagvxal +lfdtzhfadvabghna +njqmlsnrkcfhtvbb +cajzbqleghhnlgap +vmitdcozzvqvzatp +eelzefwqwjiywbcz +uyztcuptfqvymjpi +aorhnrpkjqqtgnfo +lfrxfdrduoeqmwwp +vszpjvbctblplinh +zexhadgpqfifcqrz +ueirfnshekpemqua +qfremlntihbwabtb +nwznunammfexltjc +zkyieokaaogjehwt +vlrxgkpclzeslqkq +xrqrwfsuacywczhs +olghlnfjdiwgdbqc +difnlxnedpqcsrdf +dgpuhiisybjpidsj +vlwmwrikmitmoxbt +sazpcmcnviynoktm +pratafauetiknhln +ilgteekhzwlsfwcn +ywvwhrwhkaubvkbl +qlaxivzwxyhvrxcf +hbtlwjdriizqvjfb +nrmsononytuwslsa +mpxqgdthpoipyhjc +mcdiwmiqeidwcglk +vfbaeavmjjemfrmo +qzcbzmisnynzibrc +shzmpgxhehhcejhb +wirtjadsqzydtyxd +qjlrnjfokkqvnpue +dxawdvjntlbxtuqc +wttfmnrievfestog +eamjfvsjhvzzaobg +pbvfcwzjgxahlrag +omvmjkqqnobvnzkn +lcwmeibxhhlxnkzv +uiaeroqfbvlazegs +twniyldyuonfyzqw +wgjkmsbwgfotdabi +hnomamxoxvrzvtew +ycrcfavikkrxxfgw +isieyodknagzhaxy +mgzdqwikzullzyco +mumezgtxjrrejtrs +nwmwjcgrqiwgfqel +wjgxmebfmyjnxyyp +durpspyljdykvzxf +zuslbrpooyetgafh +kuzrhcjwbdouhyme +wyxuvbciodscbvfm +kbnpvuqwmxwfqtqe +zddzercqogdpxmft +sigrdchxtgavzzjh +lznjolnorbuddgcs +ycnqabxlcajagwbt +bnaudeaexahdgxsj +rlnykxvoctfwanms +jngyetkoplrstfzt +tdpxknwacksotdub +yutqgssfoptvizgr +lzmqnxeqjfnsxmsa +iqpgfsfmukovsdgu +qywreehbidowtjyz +iozamtgusdctvnkw +ielmujhtmynlwcfd +hzxnhtbnmmejlkyf +ftbslbzmiqkzebtd +bcwdqgiiizmohack +dqhfkzeddjzbdlxu +mxopokqffisxosci +vciatxhtuechbylk +khtkhcvelidjdena +blatarwzfqcapkdt +elamngegnczctcck +xeicefdbwrxhuxuf +sawvdhjoeahlgcdr +kmdcimzsfkdfpnir +axjayzqlosrduajb +mfhzreuzzumvoggr +iqlbkbhrkptquldb +xcvztvlshiefuhgb +pkvwyqmyoazocrio +ajsxkdnerbmhyxaj +tudibgsbnpnizvsi +cxuiydkgdccrqvkh +cyztpjesdzmbcpot +nnazphxpanegwitx +uphymczbmjalmsct +yyxiwnlrogyzwqmg +gmqwnahjvvdyhnfa +utolskxpuoheugyl +mseszdhyzoyavepd +ycqknvbuvcjfgmlc +sknrxhxbfpvpeorn +zqxqjetooqcodwml +sesylkpvbndrdhsy +fryuxvjnsvnjrxlw +mfxusewqurscujnu +mbitdjjtgzchvkfv +ozwlyxtaalxofovd +wdqcduaykxbunpie +rlnhykxiraileysk +wgoqfrygttlamobg +kflxzgxvcblkpsbz +tmkisflhativzhde +owsdrfgkaamogjzd +gaupjkvkzavhfnes +wknkurddcknbdleg +lltviwincmbtduap +qwzvspgbcksyzzmb +ydzzkumecryfjgnk +jzvmwgjutxoysaam +icrwpyhxllbardkr +jdopyntshmvltrve +afgkigxcuvmdbqou +mfzzudntmvuyhjzt +duxhgtwafcgrpihc +tsnhrkvponudumeb +sqtvnbeiigdzbjgv +eczmkqwvnsrracuo +mhehsgqwiczaiaxv +kaudmfvifovrimpd +lupikgivechdbwfr +mwaaysrndiutuiqx +aacuiiwgaannunmm +tjqjbftaqitukwzp +lrcqyskykbjpaekn +lirrvofbcqpjzxmr +jurorvzpplyelfml +qonbllojmloykjqe +sllkzqujfnbauuqp +auexjwsvphvikali +usuelbssqmbrkxyc +wyuokkfjexikptvv +wmfedauwjgbrgytl +sfwvtlzzebxzmuvw +rdhqxuechjsjcvaf +kpavhqkukugocsxu +ovnjtumxowbxduts +zgerpjufauptxgat +pevvnzjfwhjxdoxq +pmmfwxajgfziszcs +difmeqvaghuitjhs +icpwjbzcmlcterwm +ngqpvhajttxuegyh +mosjlqswdngwqsmi +frlvgpxrjolgodlu +eazwgrpcxjgoszeg +bbtsthgkjrpkiiyk +tjonoglufuvsvabe +xhkbcrofytmbzrtk +kqftfzdmpbxjynps +kmeqpocbnikdtfyv +qjjymgqxhnjwxxhp +dmgicrhgbngdtmjt +zdxrhdhbdutlawnc +afvoekuhdboxghvx +hiipezngkqcnihty +bbmqgheidenweeov +suprgwxgxwfsgjnx +adeagikyamgqphrj +zzifqinoeqaorjxg +adhgppljizpaxzld +lvxyieypvvuqjiyc +nljoakatwwwoovzn +fcrkfxclcacshhmx +ownnxqtdhqbgthch +lmfylrcdmdkgpwnj +hlwjfbvlswbzpbjr +mkofhdtljdetcyvp +synyxhifbetzarpo +agnggugngadrcxoc +uhttadmdmhidpyjw +ohfwjfhunalbubpr +pzkkkkwrlvxiuysn +kmidbxmyzkjrwjhu +egtitdydwjxmajnw +civoeoiuwtwgbqqs +dfptsguzfinqoslk +tdfvkreormspprer +zvnvbrmthatzztwi +ffkyddccrrfikjde +hrrmraevdnztiwff +qaeygykcpbtjwjbr +purwhitkmrtybslh +qzziznlswjaussel +dfcxkvdpqccdqqxj +tuotforulrrytgyn +gmtgfofgucjywkev +wkyoxudvdkbgpwhd +qbvktvfvipftztnn +otckgmojziezmojb +inxhvzbtgkjxflay +qvxapbiatuudseno +krpvqosbesnjntut +oqeukkgjsfuqkjbb +prcjnyymnqwqksiz +vuortvjxgckresko +orqlyobvkuwgathr +qnpyxlnazyfuijox +zwlblfkoklqmqzkw +hmwurwtpwnrcsanl +jzvxohuakopuzgpf +sfcpnxrviphhvxmx +qtwdeadudtqhbely +dbmkmloasqphnlgj +olylnjtkxgrubmtk +nxsdbqjuvwrrdbpq +wbabpirnpcsmpipw +hjnkyiuxpqrlvims +enzpntcjnxdpuqch +vvvqhlstzcizyimn +triozhqndbttglhv +fukvgteitwaagpzx +uhcvukfbmrvskpen +tizcyupztftzxdmt +vtkpnbpdzsaluczz +wodfoyhoekidxttm +otqocljrmwfqbxzu +linfbsnfvixlwykn +vxsluutrwskslnye +zbshygtwugixjvsi +zdcqwxvwytmzhvoo +wrseozkkcyctrmei +fblgtvogvkpqzxiy +opueqnuyngegbtnf +qxbovietpacqqxok +zacrdrrkohfygddn +gbnnvjqmkdupwzpq +qgrgmsxeotozvcak +hnppukzvzfmlokid +dzbheurndscrrtcl +wbgdkadtszebbrcw +fdmzppzphhpzyuiz +bukomunhrjrypohj +ohodhelegxootqbj +rsplgzarlrknqjyh +punjjwpsxnhpzgvu +djdfahypfjvpvibm +mlgrqsmhaozatsvy +xwktrgyuhqiquxgn +wvfaoolwtkbrisvf +plttjdmguxjwmeqr +zlvvbwvlhauyjykw +cigwkbyjhmepikej +masmylenrusgtyxs +hviqzufwyetyznze +nzqfuhrooswxxhus +pdbdetaqcrqzzwxf +oehmvziiqwkzhzib +icgpyrukiokmytoy +ooixfvwtiafnwkce +rvnmgqggpjopkihs +wywualssrmaqigqk +pdbvflnwfswsrirl +jeaezptokkccpbuj +mbdwjntysntsaaby +ldlgcawkzcwuxzpz +lwktbgrzswbsweht +ecspepmzarzmgpjm +qmfyvulkmkxjncai +izftypvwngiukrns +zgmnyjfeqffbooww +nyrkhggnprhedows +yykzzrjmlevgffah +mavaemfxhlfejfki +cmegmfjbkvpncqwf +zxidlodrezztcrij +fseasudpgvgnysjv +fupcimjupywzpqzp +iqhgokavirrcvyys +wjmkcareucnmfhui +nftflsqnkgjaexhq +mgklahzlcbapntgw +kfbmeavfxtppnrxn +nuhyvhknlufdynvn +nviogjxbluwrcoec +tyozixxxaqiuvoys +kgwlvmvgtsvxojpr +moeektyhyonfdhrb +kahvevmmfsmiiqex +xcywnqzcdqtvhiwd +fnievhiyltbvtvem +jlmndqufirwgtdxd +muypbfttoeelsnbs +rypxzbnujitfwkou +ubmmjbznskildeoj +ofnmizdeicrmkjxp +rekvectjbmdnfcib +yohrojuvdexbctdh +gwfnfdeibynzjmhz +jfznhfcqdwlpjull +scrinzycfhwkmmso +mskutzossrwoqqsi +rygoebkzgyzushhr +jpjqiycflqkexemx +arbufysjqmgaapnl +dbjerflevtgweeoj +snybnnjlmwjvhois +fszuzplntraprmbj +mkvaatolvuggikvg +zpuzuqygoxesnuyc +wnpxvmxvllxalulm +eivuuafkvudeouwy +rvzckdyixetfuehr +qgmnicdoqhveahyx +miawwngyymshjmpj +pvckyoncpqeqkbmx +llninfenrfjqxurv +kzbjnlgsqjfuzqtp +rveqcmxomvpjcwte +bzotkawzbopkosnx +ktqvpiribpypaymu +wvlzkivbukhnvram +uohntlcoguvjqqdo +ajlsiksjrcnzepkt +xsqatbldqcykwusd +ihbivgzrwpmowkop +vfayesfojmibkjpb +uaqbnijtrhvqxjtb +hhovshsfmvkvymba +jerwmyxrfeyvxcgg +hncafjwrlvdcupma +qyvigggxfylbbrzt +hiiixcyohmvnkpgk +mmitpwopgxuftdfu +iaxderqpceboixoa +zodfmjhuzhnsqfcb +sthtcbadrclrazsi +bkkkkcwegvypbrio +wmpcofuvzemunlhj +gqwebiifvqoeynro +juupusqdsvxcpsgv +rbhdfhthxelolyse +kjimpwnjfrqlqhhz +rcuigrjzarzpjgfq +htxcejfyzhydinks +sxucpdxhvqjxxjwf +omsznfcimbcwaxal +gufmtdlhgrsvcosb +bssshaqujtmluerz +uukotwjkstgwijtr +kbqkneobbrdogrxk +ljqopjcjmelgrakz +rwtfnvnzryujwkfb +dedjjbrndqnilbeh +nzinsxnpptzagwlb +lwqanydfirhnhkxy +hrjuzfumbvfccxno +okismsadkbseumnp +sfkmiaiwlktxqvwa +hauwpjjwowbunbjj +nowkofejwvutcnui +bqzzppwoslaeixro +urpfgufwbtzenkpj +xgeszvuqwxeykhef +yxoldvkyuikwqyeq +onbbhxrnmohzskgg +qcikuxakrqeugpoa +lnudcqbtyzhlpers +nxduvwfrgzaailgl +xniuwvxufzxjjrwz +ljwithcqmgvntjdj +awkftfagrfzywkhs +uedtpzxyubeveuek +bhcqdwidbjkqqhzl +iyneqjdmlhowwzxx +kvshzltcrrururty +zgfpiwajegwezupo +tkrvyanujjwmyyri +ercsefuihcmoaiep +ienjrxpmetinvbos +jnwfutjbgenlipzq +bgohjmrptfuamzbz +rtsyamajrhxbcncw +tfjdssnmztvbnscs +bgaychdlmchngqlp +kfjljiobynhwfkjo +owtdxzcpqleftbvn +ltjtimxwstvzwzjj +wbrvjjjajuombokf +zblpbpuaqbkvsxye +gwgdtbpnlhyqspdi +abipqjihjqfofmkx +nlqymnuvjpvvgova +avngotmhodpoufzn +qmdyivtzitnrjuae +xfwjmqtqdljuerxi +csuellnlcyqaaamq +slqyrcurcyuoxquo +dcjmxyzbzpohzprl +uqfnmjwniyqgsowb +rbmxpqoblyxdocqc +ebjclrdbqjhladem +ainnfhxnsgwqnmyo +eyytjjwhvodtzquf +iabjgmbbhilrcyyp +pqfnehkivuelyccc +xgjbyhfgmtseiimt +jwxyqhdbjiqqqeyy +gxsbrncqkmvaryln +vhjisxjkinaejytk +seexagcdmaedpcvh +lvudfgrcpjxzdpvd +fxtegyrqjzhmqean +dnoiseraqcoossmc +nwrhmwwbykvwmgep +udmzskejvizmtlce +hbzvqhvudfdlegaa +cghmlfqejbxewskv +bntcmjqfwomtbwsb +qezhowyopjdyhzng +todzsocdkgfxanbz +zgjkssrjlwxuhwbk +eibzljqsieriyrzr +wamxvzqyycrxotjp +epzvfkispwqynadu +dwlpfhtrafrxlyie +qhgzujhgdruowoug +girstvkahaemmxvh +baitcrqmxhazyhbl +xyanqcchbhkajdmc +gfvjmmcgfhvgnfdq +tdfdbslwncbnkzyz +jojuselkpmnnbcbb +hatdslkgxtqpmavj +dvelfeddvgjcyxkj +gnsofhkfepgwltse +mdngnobasfpewlno +qssnbcyjgmkyuoga +glvcmmjytmprqwvn +gwrixumjbcdffsdl +lozravlzvfqtsuiq +sicaflbqdxbmdlch +inwfjkyyqbwpmqlq +cuvszfotxywuzhzi +igfxyoaacoarlvay +ucjfhgdmnjvgvuni +rvvkzjsytqgiposh +jduinhjjntrmqroz +yparkxbgsfnueyll +lyeqqeisxzfsqzuj +woncskbibjnumydm +lltucklragtjmxtl +ubiyvmyhlesfxotj +uecjseeicldqrqww +xxlxkbcthufnjbnm +lhqijovvhlffpxga +fzdgqpzijitlogjz +efzzjqvwphomxdpd +jvgzvuyzobeazssc +hejfycgxywfjgbfw +yhjjmvkqfbnbliks +sffvfyywtlntsdsz +dwmxqudvxqdenrur +asnukgppdemxrzaz +nwqfnumblwvdpphx +kqsmkkspqvxzuket +cpnraovljzqiquaz +qrzgrdlyyzbyykhg +opoahcbiydyhsmqe +hjknnfdauidjeydr +hczdjjlygoezadow +rtflowzqycimllfv +sfsrgrerzlnychhq +bpahuvlblcolpjmj +albgnjkgmcrlaicl +pijyqdhfxpaxzdex +eeymiddvcwkpbpux +rqwkqoabywgggnln +vckbollyhgbgmgwh +ylzlgvnuvpynybkm +hpmbxtpfosbsjixt +ocebeihnhvkhjfqz +tvctyxoujdgwayze +efvhwxtuhapqxjen +rusksgefyidldmpo +nkmtjvddfmhirmzz +whvtsuadwofzmvrt +iiwjqvsdxudhdzzk +gucirgxaxgcassyo +rmhfasfzexeykwmr +hynlxcvsbgosjbis +huregszrcaocueen +pifezpoolrnbdqtv +unatnixzvdbqeyox +xtawlpduxgacchfe +bdvdbflqfphndduf +xtdsnjnmzccfptyt +nkhsdkhqtzqbphhg +aqcubmfkczlaxiyb +moziflxpsfubucmv +srdgnnjtfehiimqx +pwfalehdfyykrohf +sysxssmvewyfjrve +brsemdzosgqvvlxe +bimbjoshuvflkiat +hkgjasmljkpkwwku +sbnmwjvodygobpqc +bbbqycejueruihhd +corawswvlvneipyc +gcyhknmwsczcxedh +kppakbffdhntmcqp +ynulzwkfaemkcefp +pyroowjekeurlbii +iwksighrswdcnmxf +glokrdmugreygnsg +xkmvvumnfzckryop +aesviofpufygschi +csloawlirnegsssq +fkqdqqmlzuxbkzbc +uzlhzcfenxdfjdzp +poaaidrktteusvyf +zrlyfzmjzfvivcfr +qwjulskbniitgqtx +gjeszjksbfsuejki +vczdejdbfixbduaq +knjdrjthitjxluth +jweydeginrnicirl +bottrfgccqhyycsl +eiquffofoadmbuhk +lbqfutmzoksscswf +xfmdvnvfcnzjprba +uvugkjbkhlaoxmyx +wadlgtpczgvcaqqv +inzrszbtossflsxk +dbzbtashaartczrj +qbjiqpccefcfkvod +hluujmokjywotvzy +thwlliksfztcmwzh +arahybspdaqdexrq +nuojrmsgyipdvwyx +hnajdwjwmzattvst +sulcgaxezkprjbgu +rjowuugwdpkjtypw +oeugzwuhnrgiaqga +wvxnyymwftfoswij +pqxklzkjpcqscvde +tuymjzknntekglqj +odteewktugcwlhln +exsptotlfecmgehc +eeswfcijtvzgrqel +vjhrkiwmunuiwqau +zhlixepkeijoemne +pavfsmwesuvebzdd +jzovbklnngfdmyws +nbajyohtzfeoiixz +ciozmhrsjzrwxvhz +gwucrxieqbaqfjuv +uayrxrltnohexawc +flmrbhwsfbcquffm +gjyabmngkitawlxc +rwwtggvaygfbovhg +xquiegaisynictjq +oudzwuhexrwwdbyy +lengxmguyrwhrebb +uklxpglldbgqsjls +dbmvlfeyguydfsxq +zspdwdqcrmtmdtsc +mqfnzwbfqlauvrgc +amcrkzptgacywvhv +ndxmskrwrqysrndf +mwjyhsufeqhwisju +srlrukoaenyevykt +tnpjtpwawrxbikct +geczalxmgxejulcv +tvkcbqdhmuwcxqci +tiovluvwezwwgaox +zrjhtbgajkjqzmfo +vcrywduwsklepirs +lofequdigsszuioy +wxsdzomkjqymlzat +iabaczqtrfbmypuy +ibdlmudbajikcncr +rqcvkzsbwmavdwnv +ypxoyjelhllhbeog +fdnszbkezyjbttbg +uxnhrldastpdjkdz +xfrjbehtxnlyzcka +omjyfhbibqwgcpbv +eguucnoxaoprszmp +xfpypldgcmcllyzz +aypnmgqjxjqceelv +mgzharymejlafvgf +tzowgwsubbaigdok +ilsehjqpcjwmylxc +pfmouwntfhfnmrwk +csgokybgdqwnduwp +eaxwvxvvwbrovypz +nmluqvobbbmdiwwb +lnkminvfjjzqbmio +mjiiqzycqdhfietz +towlrzriicyraevq +obiloewdvbrsfwjo +lmeooaajlthsfltw +ichygipzpykkesrw +gfysloxmqdsfskvt +saqzntehjldvwtsx +pqddoemaufpfcaew +mjrxvbvwcreaybwe +ngfbrwfqnxqosoai +nesyewxreiqvhald +kqhqdlquywotcyfy +liliptyoqujensfi +nsahsaxvaepzneqq +zaickulfjajhctye +gxjzahtgbgbabtht +koxbuopaqhlsyhrp +jhzejdjidqqtjnwe +dekrkdvprfqpcqki +linwlombdqtdeyop +dvckqqbnigdcmwmx +yaxygbjpzkvnnebv +rlzkdkgaagmcpxah +cfzuyxivtknirqvt +obivkajhsjnrxxhn +lmjhayymgpseuynn +bbjyewkwadaipyju +lmzyhwomfypoftuu +gtzhqlgltvatxack +jfflcfaqqkrrltgq +txoummmnzfrlrmcg +ohemsbfuqqpucups +imsfvowcbieotlok +tcnsnccdszxfcyde +qkcdtkwuaquajazz +arcfnhmdjezdbqku +srnocgyqrlcvlhkb +mppbzvfmcdirbyfw +xiuarktilpldwgwd +ypufwmhrvzqmexpc +itpdnsfkwgrdujmj +cmpxnodtsswkyxkr +wayyxtjklfrmvbfp +mfaxphcnjczhbbwy +sjxhgwdnqcofbdra +pnxmujuylqccjvjm +ivamtjbvairwjqwl +deijtmzgpfxrclss +bzkqcaqagsynlaer +tycefobvxcvwaulz +ctbhnywezxkdsswf +urrxxebxrthtjvib +fpfelcigwqwdjucv +ngfcyyqpqulwcphb +rltkzsiipkpzlgpw +qfdsymzwhqqdkykc +balrhhxipoqzmihj +rnwalxgigswxomga +ghqnxeogckshphgr +lyyaentdizaumnla +exriodwfzosbeoib +speswfggibijfejk +yxmxgfhvmshqszrq +hcqhngvahzgawjga +qmhlsrfpesmeksur +eviafjejygakodla +kvcfeiqhynqadbzv +fusvyhowslfzqttg +girqmvwmcvntrwau +yuavizroykfkdekz +jmcwohvmzvowrhxf +kzimlcpavapynfue +wjudcdtrewfabppq +yqpteuxqgbmqfgxh +xdgiszbuhdognniu +jsguxfwhpftlcjoh +whakkvspssgjzxre +ggvnvjurlyhhijgm +krvbhjybnpemeptr +pqedgfojyjybfbzr +jzhcrsgmnkwwtpdo +yyscxoxwofslncmp +gzjhnxytmyntzths +iteigbnqbtpvqumi +zjevfzusnjukqpfw +xippcyhkfuounxqk +mcnhrcfonfdgpkyh +pinkcyuhjkexbmzj +lotxrswlxbxlxufs +fmqajrtoabpckbnu +wfkwsgmcffdgaqxg +qfrsiwnohoyfbidr +czfqbsbmiuyusaqs +ieknnjeecucghpoo +cevdgqnugupvmsge +gjkajcyjnxdrtuvr +udzhrargnujxiclq +zqqrhhmjwermjssg +ggdivtmgoqajydzz +wnpfsgtxowkjiivl +afbhqawjbotxnqpd +xjpkifkhfjeqifdn +oyfggzsstfhvticp +kercaetahymeawxy +khphblhcgmbupmzt +iggoqtqpvaebtiol +ofknifysuasshoya +qxuewroccsbogrbv +apsbnbkiopopytgu +zyahfroovfjlythh +bxhjwfgeuxlviydq +uvbhdtvaypasaswa +qamcjzrmesqgqdiz +hjnjyzrxntiycyel +wkcrwqwniczwdxgq +hibxlvkqakusswkx +mzjyuenepwdgrkty +tvywsoqslfsulses +jqwcwuuisrclircv +xanwaoebfrzhurct +ykriratovsvxxasf +qyebvtqqxbjuuwuo +telrvlwvriylnder +acksrrptgnhkeiaa +yemwfjhiqlzsvdxf +banrornfkcymmkcc +ytbhxvaeiigjpcgm +crepyazgxquposkn +xlqwdrytzwnxzwzv +xtrbfbwopxscftps +kwbytzukgseeyjla +qtfdvavvjogybxjg +ytbmvmrcxwfkgvzw +nbscbdskdeocnfzr +sqquwjbdxsxhcseg +ewqxhigqcgszfsuw +cvkyfcyfmubzwsee +dcoawetekigxgygd +ohgqnqhfimyuqhvi +otisopzzpvnhctte +bauieohjejamzien +ewnnopzkujbvhwce +aeyqlskpaehagdiv +pncudvivwnnqspxy +ytugesilgveokxcg +zoidxeelqdjesxpr +ducjccsuaygfchzj +smhgllqqqcjfubfc +nlbyyywergronmir +prdawpbjhrzsbsvj +nmgzhnjhlpcplmui +eflaogtjghdjmxxz +qolvpngucbkprrdc +ixywxcienveltgho +mwnpqtocagenkxut +iskrfbwxonkguywx +ouhtbvcaczqzmpua +srewprgddfgmdbao +dyufrltacelchlvu +czmzcbrkecixuwzz +dtbeojcztzauofuk +prrgoehpqhngfgmw +baolzvfrrevxsyke +zqadgxshwiarkzwh +vsackherluvurqqj +surbpxdulvcvgjbd +wqxytarcxzgxhvtx +vbcubqvejcfsgrac +zqnjfeapshjowzja +hekvbhtainkvbynx +knnugxoktxpvoxnh +knoaalcefpgtvlwm +qoakaunowmsuvkus +ypkvlzcduzlezqcb +ujhcagawtyepyogh +wsilcrxncnffaxjf +gbbycjuscquaycrk +aduojapeaqwivnly +ceafyxrakviagcjy +nntajnghicgnrlst +vdodpeherjmmvbje +wyyhrnegblwvdobn +xlfurpghkpbzhhif +xyppnjiljvirmqjo +kglzqahipnddanpi +omjateouxikwxowr +ocifnoopfglmndcx +emudcukfbadyijev +ooktviixetfddfmh +wtvrhloyjewdeycg +cgjncqykgutfjhvb +nkwvpswppeffmwad +hqbcmfhzkxmnrivg +mdskbvzguxvieilr +anjcvqpavhdloaqh +erksespdevjylenq +fadxwbmisazyegup +iyuiffjmcaahowhj +ygkdezmynmltodbv +fytneukxqkjattvh +woerxfadbfrvdcnz +iwsljvkyfastccoa +movylhjranlorofe +drdmicdaiwukemep +knfgtsmuhfcvvshg +ibstpbevqmdlhajn +tstwsswswrxlzrqs +estyydmzothggudf +jezogwvymvikszwa +izmqcwdyggibliet +nzpxbegurwnwrnca +kzkojelnvkwfublh +xqcssgozuxfqtiwi +tcdoigumjrgvczfv +ikcjyubjmylkwlwq +kqfivwystpqzvhan +bzukgvyoqewniivj +iduapzclhhyfladn +fbpyzxdfmkrtfaeg +yzsmlbnftftgwadz diff --git a/2015/day05/main.go b/2015/day05/main.go new file mode 100644 index 0000000..69fdbe0 --- /dev/null +++ b/2015/day05/main.go @@ -0,0 +1,82 @@ +package main + +import ( + "fmt" + "io" + "log" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + + var numNice int + for _, k := range input { + if isNicePt2(k) { + numNice++ + } + } + fmt.Printf("There are %d nice strings (out of %d total)\n", numNice, len(input)) +} + +func isNicePt1(s string) bool { + var prev byte + var numVowels int + var hasDouble bool + for i := range s { + if s[i] == 'b' && prev == 'a' { + return false + } else if s[i] == 'd' && prev == 'c' { + return false + } else if s[i] == 'q' && prev == 'p' { + return false + } else if s[i] == 'y' && prev == 'x' { + return false + } else if s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' { + numVowels++ + } + if prev == s[i] { + hasDouble = true + } + prev = s[i] + } + return (numVowels > 2 && hasDouble) +} + +func isNicePt2(s string) bool { + var splitRepeat bool + var double bool + for i := range s { + if i > 0 { + double = double || hasDouble(s[i-1], s[i], s[i+1:]) + } + if i > 1 { + splitRepeat = splitRepeat || (s[i-2] == s[i]) + } + if double && splitRepeat { + return true + } + } + return false +} + +func hasDouble(b1, b2 byte, s string) bool { + var prev byte + for i := range s { + if prev == b1 && s[i] == b2 { + return true + } + prev = s[i] + } + return false +} diff --git a/2015/day05/problem b/2015/day05/problem new file mode 100644 index 0000000..b872a1e --- /dev/null +++ b/2015/day05/problem @@ -0,0 +1,85 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 5: Doesn't He Have Intern-Elves For This? --- + + Santa needs help figuring out which strings in his text file are naughty or nice. + + A nice string is one with all of the following properties: + + • It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou. + • It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or + aabbccdd (aa, bb, cc, or dd). + • It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the + other requirements. + + For example: + + • ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double + letter (...dd...), and none of the disallowed substrings. + • aaa is nice because it has at least three vowels and a double letter, even though the + letters used by different rules overlap. + • jchzalrnumimnmhp is naughty because it has no double letter. + • haegwjzuvuyypxyu is naughty because it contains the string xy. + • dvszwmarrgswjxmb is naughty because it contains only one vowel. + + How many strings are nice? + + Your puzzle answer was 255. + +--- Part Two --- + + Realizing the error of his ways, Santa has switched to a better model of determining whether a + string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. + + Now, a nice string is one with all of the following properties: + + • It contains a pair of any two letters that appears at least twice in the string without + overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). + • It contains at least one letter which repeats with exactly one letter between them, like + xyx, abcdefeghi (efe), or even aaa. + + For example: + + • qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that + repeats with exactly one letter between them (zxz). + • xxyxx is nice because it has a pair that appears twice and a letter that repeats with one + between, even though the letters used by each rule overlap. + • uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter + between them. + • ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but + no pair that appears twice. + + How many strings are nice under these new rules? + + Your puzzle answer was 55. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/5/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Doesn%27t+He+Have+Intern%2DElves+For+This%3F%22+%2D+Day+5+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5&title=I%27ve+completed+%22Doesn%27t+He+Have+Intern%2DElves+For+This%3F%22+%2D+Day+5+%2D+Advent+of+Code diff --git a/2015/day06/input b/2015/day06/input new file mode 100644 index 0000000..c4357c6 --- /dev/null +++ b/2015/day06/input @@ -0,0 +1,300 @@ +turn on 887,9 through 959,629 +turn on 454,398 through 844,448 +turn off 539,243 through 559,965 +turn off 370,819 through 676,868 +turn off 145,40 through 370,997 +turn off 301,3 through 808,453 +turn on 351,678 through 951,908 +toggle 720,196 through 897,994 +toggle 831,394 through 904,860 +toggle 753,664 through 970,926 +turn off 150,300 through 213,740 +turn on 141,242 through 932,871 +toggle 294,259 through 474,326 +toggle 678,333 through 752,957 +toggle 393,804 through 510,976 +turn off 6,964 through 411,976 +turn off 33,572 through 978,590 +turn on 579,693 through 650,978 +turn on 150,20 through 652,719 +turn off 782,143 through 808,802 +turn off 240,377 through 761,468 +turn off 899,828 through 958,967 +turn on 613,565 through 952,659 +turn on 295,36 through 964,978 +toggle 846,296 through 969,528 +turn off 211,254 through 529,491 +turn off 231,594 through 406,794 +turn off 169,791 through 758,942 +turn on 955,440 through 980,477 +toggle 944,498 through 995,928 +turn on 519,391 through 605,718 +toggle 521,303 through 617,366 +turn off 524,349 through 694,791 +toggle 391,87 through 499,792 +toggle 562,527 through 668,935 +turn off 68,358 through 857,453 +toggle 815,811 through 889,828 +turn off 666,61 through 768,87 +turn on 27,501 through 921,952 +turn on 953,102 through 983,471 +turn on 277,552 through 451,723 +turn off 64,253 through 655,960 +turn on 47,485 through 734,977 +turn off 59,119 through 699,734 +toggle 407,898 through 493,955 +toggle 912,966 through 949,991 +turn on 479,990 through 895,990 +toggle 390,589 through 869,766 +toggle 593,903 through 926,943 +toggle 358,439 through 870,528 +turn off 649,410 through 652,875 +turn on 629,834 through 712,895 +toggle 254,555 through 770,901 +toggle 641,832 through 947,850 +turn on 268,448 through 743,777 +turn off 512,123 through 625,874 +turn off 498,262 through 930,811 +turn off 835,158 through 886,242 +toggle 546,310 through 607,773 +turn on 501,505 through 896,909 +turn off 666,796 through 817,924 +toggle 987,789 through 993,809 +toggle 745,8 through 860,693 +toggle 181,983 through 731,988 +turn on 826,174 through 924,883 +turn on 239,228 through 843,993 +turn on 205,613 through 891,667 +toggle 867,873 through 984,896 +turn on 628,251 through 677,681 +toggle 276,956 through 631,964 +turn on 78,358 through 974,713 +turn on 521,360 through 773,597 +turn off 963,52 through 979,502 +turn on 117,151 through 934,622 +toggle 237,91 through 528,164 +turn on 944,269 through 975,453 +toggle 979,460 through 988,964 +turn off 440,254 through 681,507 +toggle 347,100 through 896,785 +turn off 329,592 through 369,985 +turn on 931,960 through 979,985 +toggle 703,3 through 776,36 +toggle 798,120 through 908,550 +turn off 186,605 through 914,709 +turn off 921,725 through 979,956 +toggle 167,34 through 735,249 +turn on 726,781 through 987,936 +toggle 720,336 through 847,756 +turn on 171,630 through 656,769 +turn off 417,276 through 751,500 +toggle 559,485 through 584,534 +turn on 568,629 through 690,873 +toggle 248,712 through 277,988 +toggle 345,594 through 812,723 +turn off 800,108 through 834,618 +turn off 967,439 through 986,869 +turn on 842,209 through 955,529 +turn on 132,653 through 357,696 +turn on 817,38 through 973,662 +turn off 569,816 through 721,861 +turn on 568,429 through 945,724 +turn on 77,458 through 844,685 +turn off 138,78 through 498,851 +turn on 136,21 through 252,986 +turn off 2,460 through 863,472 +turn on 172,81 through 839,332 +turn on 123,216 through 703,384 +turn off 879,644 through 944,887 +toggle 227,491 through 504,793 +toggle 580,418 through 741,479 +toggle 65,276 through 414,299 +toggle 482,486 through 838,931 +turn off 557,768 through 950,927 +turn off 615,617 through 955,864 +turn on 859,886 through 923,919 +turn on 391,330 through 499,971 +toggle 521,835 through 613,847 +turn on 822,787 through 989,847 +turn on 192,142 through 357,846 +turn off 564,945 through 985,945 +turn off 479,361 through 703,799 +toggle 56,481 through 489,978 +turn off 632,991 through 774,998 +toggle 723,526 through 945,792 +turn on 344,149 through 441,640 +toggle 568,927 through 624,952 +turn on 621,784 through 970,788 +toggle 665,783 through 795,981 +toggle 386,610 through 817,730 +toggle 440,399 through 734,417 +toggle 939,201 through 978,803 +turn off 395,883 through 554,929 +turn on 340,309 through 637,561 +turn off 875,147 through 946,481 +turn off 945,837 through 957,922 +turn off 429,982 through 691,991 +toggle 227,137 through 439,822 +toggle 4,848 through 7,932 +turn off 545,146 through 756,943 +turn on 763,863 through 937,994 +turn on 232,94 through 404,502 +turn off 742,254 through 930,512 +turn on 91,931 through 101,942 +toggle 585,106 through 651,425 +turn on 506,700 through 567,960 +turn off 548,44 through 718,352 +turn off 194,827 through 673,859 +turn off 6,645 through 509,764 +turn off 13,230 through 821,361 +turn on 734,629 through 919,631 +toggle 788,552 through 957,972 +toggle 244,747 through 849,773 +turn off 162,553 through 276,887 +turn off 569,577 through 587,604 +turn off 799,482 through 854,956 +turn on 744,535 through 909,802 +toggle 330,641 through 396,986 +turn off 927,458 through 966,564 +toggle 984,486 through 986,913 +toggle 519,682 through 632,708 +turn on 984,977 through 989,986 +toggle 766,423 through 934,495 +turn on 17,509 through 947,718 +turn on 413,783 through 631,903 +turn on 482,370 through 493,688 +turn on 433,859 through 628,938 +turn off 769,549 through 945,810 +turn on 178,853 through 539,941 +turn off 203,251 through 692,433 +turn off 525,638 through 955,794 +turn on 169,70 through 764,939 +toggle 59,352 through 896,404 +toggle 143,245 through 707,320 +turn off 103,35 through 160,949 +toggle 496,24 through 669,507 +turn off 581,847 through 847,903 +turn on 689,153 through 733,562 +turn on 821,487 through 839,699 +turn on 837,627 through 978,723 +toggle 96,748 through 973,753 +toggle 99,818 through 609,995 +turn on 731,193 through 756,509 +turn off 622,55 through 813,365 +turn on 456,490 through 576,548 +turn on 48,421 through 163,674 +turn off 853,861 through 924,964 +turn off 59,963 through 556,987 +turn on 458,710 through 688,847 +toggle 12,484 through 878,562 +turn off 241,964 through 799,983 +turn off 434,299 through 845,772 +toggle 896,725 through 956,847 +turn on 740,289 through 784,345 +turn off 395,840 through 822,845 +turn on 955,224 through 996,953 +turn off 710,186 through 957,722 +turn off 485,949 through 869,985 +turn on 848,209 through 975,376 +toggle 221,241 through 906,384 +turn on 588,49 through 927,496 +turn on 273,332 through 735,725 +turn on 505,962 through 895,962 +toggle 820,112 through 923,143 +turn on 919,792 through 978,982 +toggle 489,461 through 910,737 +turn off 202,642 through 638,940 +turn off 708,953 through 970,960 +toggle 437,291 through 546,381 +turn on 409,358 through 837,479 +turn off 756,279 through 870,943 +turn off 154,657 through 375,703 +turn off 524,622 through 995,779 +toggle 514,221 through 651,850 +toggle 808,464 through 886,646 +toggle 483,537 through 739,840 +toggle 654,769 through 831,825 +turn off 326,37 through 631,69 +turn off 590,570 through 926,656 +turn off 881,913 through 911,998 +turn on 996,102 through 998,616 +turn off 677,503 through 828,563 +turn on 860,251 through 877,441 +turn off 964,100 through 982,377 +toggle 888,403 through 961,597 +turn off 632,240 through 938,968 +toggle 731,176 through 932,413 +turn on 5,498 through 203,835 +turn on 819,352 through 929,855 +toggle 393,813 through 832,816 +toggle 725,689 through 967,888 +turn on 968,950 through 969,983 +turn off 152,628 through 582,896 +turn off 165,844 through 459,935 +turn off 882,741 through 974,786 +turn off 283,179 through 731,899 +toggle 197,366 through 682,445 +turn on 106,309 through 120,813 +toggle 950,387 through 967,782 +turn off 274,603 through 383,759 +turn off 155,665 through 284,787 +toggle 551,871 through 860,962 +turn off 30,826 through 598,892 +toggle 76,552 through 977,888 +turn on 938,180 through 994,997 +toggle 62,381 through 993,656 +toggle 625,861 through 921,941 +turn on 685,311 through 872,521 +turn on 124,934 through 530,962 +turn on 606,379 through 961,867 +turn off 792,735 through 946,783 +turn on 417,480 through 860,598 +toggle 178,91 through 481,887 +turn off 23,935 through 833,962 +toggle 317,14 through 793,425 +turn on 986,89 through 999,613 +turn off 359,201 through 560,554 +turn off 729,494 through 942,626 +turn on 204,143 through 876,610 +toggle 474,97 through 636,542 +turn off 902,924 through 976,973 +turn off 389,442 through 824,638 +turn off 622,863 through 798,863 +turn on 840,622 through 978,920 +toggle 567,374 through 925,439 +turn off 643,319 through 935,662 +toggle 185,42 through 294,810 +turn on 47,124 through 598,880 +toggle 828,303 through 979,770 +turn off 174,272 through 280,311 +turn off 540,50 through 880,212 +turn on 141,994 through 221,998 +turn on 476,695 through 483,901 +turn on 960,216 through 972,502 +toggle 752,335 through 957,733 +turn off 419,713 through 537,998 +toggle 772,846 through 994,888 +turn on 881,159 through 902,312 +turn off 537,651 through 641,816 +toggle 561,947 through 638,965 +turn on 368,458 through 437,612 +turn on 290,149 through 705,919 +turn on 711,918 through 974,945 +toggle 916,242 through 926,786 +toggle 522,272 through 773,314 +turn on 432,897 through 440,954 +turn off 132,169 through 775,380 +toggle 52,205 through 693,747 +toggle 926,309 through 976,669 +turn off 838,342 through 938,444 +turn on 144,431 through 260,951 +toggle 780,318 through 975,495 +turn off 185,412 through 796,541 +turn on 879,548 through 892,860 +turn on 294,132 through 460,338 +turn on 823,500 through 899,529 +turn off 225,603 through 483,920 +toggle 717,493 through 930,875 +toggle 534,948 through 599,968 +turn on 522,730 through 968,950 +turn off 102,229 through 674,529 diff --git a/2015/day06/main.go b/2015/day06/main.go new file mode 100644 index 0000000..00c78d6 --- /dev/null +++ b/2015/day06/main.go @@ -0,0 +1,70 @@ +package main + +import ( + "fmt" + "io" + "log" + "os" + "strconv" + "strings" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + + var lights [][]int + for i := 0; i < 1000; i++ { + lights = append(lights, make([]int, 1000)) + } + for i := range input { + if input[i] == "on" || input[i] == "off" || input[i] == "toggle" { + stX, stY := parseLocations(input[i+1]) + endX, endY := parseLocations(input[i+3]) + for ix := stX; ix <= endX; ix++ { + for iy := stY; iy <= endY; iy++ { + if input[i] == "on" { + lights[ix][iy]++ + } else if input[i] == "off" { + if lights[ix][iy] > 0 { + lights[ix][iy]-- + } + } else if input[i] == "toggle" { + lights[ix][iy] += 2 + } + } + } + } + } + var brightness int + for i := 0; i < 1000; i++ { + for j := 0; j < 1000; j++ { + brightness += lights[i][j] + } + } + fmt.Printf("Brightness: %d\n", brightness) +} + +func parseLocations(s string) (int, int) { + dirSplit := strings.Split(s, ",") + return assertAtoi(dirSplit[0]), assertAtoi(dirSplit[1]) +} + +func assertAtoi(s string) int { + ret, err := strconv.Atoi(s) + if err != nil { + fmt.Println("Error in Atoi: " + s) + os.Exit(1) + } + return ret +} diff --git a/2015/day06/problem b/2015/day06/problem new file mode 100644 index 0000000..7135358 --- /dev/null +++ b/2015/day06/problem @@ -0,0 +1,84 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 6: Probably a Fire Hazard --- + + Because your neighbors keep defeating you in the holiday house decorating contest year after + year, you've decided to deploy one million lights in a 1000x1000 grid. + + Furthermore, because you've been especially nice this year, Santa has mailed you instructions + on how to display the ideal lighting configuration. + + Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are + at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or + toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents + opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore + refers to 9 lights in a 3x3 square. The lights all start turned off. + + To defeat your neighbors this year, all you have to do is set up your lights by doing the + instructions Santa sent you in order. + + For example: + + • turn on 0,0 through 999,999 would turn on (or leave on) every light. + • toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones + that were on, and turning on the ones that were off. + • turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. + + After following the instructions, how many lights are lit? + + Your puzzle answer was 377891. + +--- Part Two --- + + You just finish implementing your winning light pattern when you realize you mistranslated + Santa's message from Ancient Nordic Elvish. + + The light grid you bought actually has individual brightness controls; each light can have a + brightness of zero or more. The lights all start at zero. + + The phrase turn on actually means that you should increase the brightness of those lights by 1. + + The phrase turn off actually means that you should decrease the brightness of those lights by + 1, to a minimum of zero. + + The phrase toggle actually means that you should increase the brightness of those lights by 2. + + What is the total brightness of all lights combined after following Santa's instructions? + + For example: + + • turn on 0,0 through 0,0 would increase the total brightness by 1. + • toggle 0,0 through 999,999 would increase the total brightness by 2000000. + + Your puzzle answer was 14110788. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/6/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Probably+a+Fire+Hazard%22+%2D+Day+6+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6&title=I%27ve+completed+%22Probably+a+Fire+Hazard%22+%2D+Day+6+%2D+Advent+of+Code diff --git a/2015/day07/input b/2015/day07/input new file mode 100644 index 0000000..de11a72 --- /dev/null +++ b/2015/day07/input @@ -0,0 +1,339 @@ +lf AND lq -> ls +iu RSHIFT 1 -> jn +bo OR bu -> bv +gj RSHIFT 1 -> hc +et RSHIFT 2 -> eu +bv AND bx -> by +is OR it -> iu +b OR n -> o +gf OR ge -> gg +NOT kt -> ku +ea AND eb -> ed +kl OR kr -> ks +hi AND hk -> hl +au AND av -> ax +lf RSHIFT 2 -> lg +dd RSHIFT 3 -> df +eu AND fa -> fc +df AND dg -> di +ip LSHIFT 15 -> it +NOT el -> em +et OR fe -> ff +fj LSHIFT 15 -> fn +t OR s -> u +ly OR lz -> ma +ko AND kq -> kr +NOT fx -> fy +et RSHIFT 1 -> fm +eu OR fa -> fb +dd RSHIFT 2 -> de +NOT go -> gp +kb AND kd -> ke +hg OR hh -> hi +jm LSHIFT 1 -> kg +NOT cn -> co +jp RSHIFT 2 -> jq +jp RSHIFT 5 -> js +1 AND io -> ip +eo LSHIFT 15 -> es +1 AND jj -> jk +g AND i -> j +ci RSHIFT 3 -> ck +gn AND gp -> gq +fs AND fu -> fv +lj AND ll -> lm +jk LSHIFT 15 -> jo +iu RSHIFT 3 -> iw +NOT ii -> ij +1 AND cc -> cd +bn RSHIFT 3 -> bp +NOT gw -> gx +NOT ft -> fu +jn OR jo -> jp +iv OR jb -> jc +hv OR hu -> hw +16076 -> b +gj RSHIFT 5 -> gm +hq AND hs -> ht +dy RSHIFT 1 -> er +ao OR an -> ap +ld OR le -> lf +bk LSHIFT 1 -> ce +bz AND cb -> cc +bi LSHIFT 15 -> bm +il AND in -> io +af AND ah -> ai +as RSHIFT 1 -> bl +lf RSHIFT 3 -> lh +er OR es -> et +NOT ax -> ay +ci RSHIFT 1 -> db +et AND fe -> fg +lg OR lm -> ln +k AND m -> n +hz RSHIFT 2 -> ia +kh LSHIFT 1 -> lb +NOT ey -> ez +NOT di -> dj +dz OR ef -> eg +lx -> a +NOT iz -> ja +gz LSHIFT 15 -> hd +ce OR cd -> cf +fq AND fr -> ft +at AND az -> bb +ha OR gz -> hb +fp AND fv -> fx +NOT gb -> gc +ia AND ig -> ii +gl OR gm -> gn +0 -> c +NOT ca -> cb +bn RSHIFT 1 -> cg +c LSHIFT 1 -> t +iw OR ix -> iy +kg OR kf -> kh +dy OR ej -> ek +km AND kn -> kp +NOT fc -> fd +hz RSHIFT 3 -> ib +NOT dq -> dr +NOT fg -> fh +dy RSHIFT 2 -> dz +kk RSHIFT 2 -> kl +1 AND fi -> fj +NOT hr -> hs +jp RSHIFT 1 -> ki +bl OR bm -> bn +1 AND gy -> gz +gr AND gt -> gu +db OR dc -> dd +de OR dk -> dl +as RSHIFT 5 -> av +lf RSHIFT 5 -> li +hm AND ho -> hp +cg OR ch -> ci +gj AND gu -> gw +ge LSHIFT 15 -> gi +e OR f -> g +fp OR fv -> fw +fb AND fd -> fe +cd LSHIFT 15 -> ch +b RSHIFT 1 -> v +at OR az -> ba +bn RSHIFT 2 -> bo +lh AND li -> lk +dl AND dn -> do +eg AND ei -> ej +ex AND ez -> fa +NOT kp -> kq +NOT lk -> ll +x AND ai -> ak +jp OR ka -> kb +NOT jd -> je +iy AND ja -> jb +jp RSHIFT 3 -> jr +fo OR fz -> ga +df OR dg -> dh +gj RSHIFT 2 -> gk +gj OR gu -> gv +NOT jh -> ji +ap LSHIFT 1 -> bj +NOT ls -> lt +ir LSHIFT 1 -> jl +bn AND by -> ca +lv LSHIFT 15 -> lz +ba AND bc -> bd +cy LSHIFT 15 -> dc +ln AND lp -> lq +x RSHIFT 1 -> aq +gk OR gq -> gr +NOT kx -> ky +jg AND ji -> jj +bn OR by -> bz +fl LSHIFT 1 -> gf +bp OR bq -> br +he OR hp -> hq +et RSHIFT 5 -> ew +iu RSHIFT 2 -> iv +gl AND gm -> go +x OR ai -> aj +hc OR hd -> he +lg AND lm -> lo +lh OR li -> lj +da LSHIFT 1 -> du +fo RSHIFT 2 -> fp +gk AND gq -> gs +bj OR bi -> bk +lf OR lq -> lr +cj AND cp -> cr +hu LSHIFT 15 -> hy +1 AND bh -> bi +fo RSHIFT 3 -> fq +NOT lo -> lp +hw LSHIFT 1 -> iq +dd RSHIFT 1 -> dw +dt LSHIFT 15 -> dx +dy AND ej -> el +an LSHIFT 15 -> ar +aq OR ar -> as +1 AND r -> s +fw AND fy -> fz +NOT im -> in +et RSHIFT 3 -> ev +1 AND ds -> dt +ec AND ee -> ef +NOT ak -> al +jl OR jk -> jm +1 AND en -> eo +lb OR la -> lc +iu AND jf -> jh +iu RSHIFT 5 -> ix +bo AND bu -> bw +cz OR cy -> da +iv AND jb -> jd +iw AND ix -> iz +lf RSHIFT 1 -> ly +iu OR jf -> jg +NOT dm -> dn +lw OR lv -> lx +gg LSHIFT 1 -> ha +lr AND lt -> lu +fm OR fn -> fo +he RSHIFT 3 -> hg +aj AND al -> am +1 AND kz -> la +dy RSHIFT 5 -> eb +jc AND je -> jf +cm AND co -> cp +gv AND gx -> gy +ev OR ew -> ex +jp AND ka -> kc +fk OR fj -> fl +dy RSHIFT 3 -> ea +NOT bs -> bt +NOT ag -> ah +dz AND ef -> eh +cf LSHIFT 1 -> cz +NOT cv -> cw +1 AND cx -> cy +de AND dk -> dm +ck AND cl -> cn +x RSHIFT 5 -> aa +dv LSHIFT 1 -> ep +he RSHIFT 2 -> hf +NOT bw -> bx +ck OR cl -> cm +bp AND bq -> bs +as OR bd -> be +he AND hp -> hr +ev AND ew -> ey +1 AND lu -> lv +kk RSHIFT 3 -> km +b AND n -> p +NOT kc -> kd +lc LSHIFT 1 -> lw +km OR kn -> ko +id AND if -> ig +ih AND ij -> ik +jr AND js -> ju +ci RSHIFT 5 -> cl +hz RSHIFT 1 -> is +1 AND ke -> kf +NOT gs -> gt +aw AND ay -> az +x RSHIFT 2 -> y +ab AND ad -> ae +ff AND fh -> fi +ci AND ct -> cv +eq LSHIFT 1 -> fk +gj RSHIFT 3 -> gl +u LSHIFT 1 -> ao +NOT bb -> bc +NOT hj -> hk +kw AND ky -> kz +as AND bd -> bf +dw OR dx -> dy +br AND bt -> bu +kk AND kv -> kx +ep OR eo -> eq +he RSHIFT 1 -> hx +ki OR kj -> kk +NOT ju -> jv +ek AND em -> en +kk RSHIFT 5 -> kn +NOT eh -> ei +hx OR hy -> hz +ea OR eb -> ec +s LSHIFT 15 -> w +fo RSHIFT 1 -> gh +kk OR kv -> kw +bn RSHIFT 5 -> bq +NOT ed -> ee +1 AND ht -> hu +cu AND cw -> cx +b RSHIFT 5 -> f +kl AND kr -> kt +iq OR ip -> ir +ci RSHIFT 2 -> cj +cj OR cp -> cq +o AND q -> r +dd RSHIFT 5 -> dg +b RSHIFT 2 -> d +ks AND ku -> kv +b RSHIFT 3 -> e +d OR j -> k +NOT p -> q +NOT cr -> cs +du OR dt -> dv +kf LSHIFT 15 -> kj +NOT ac -> ad +fo RSHIFT 5 -> fr +hz OR ik -> il +jx AND jz -> ka +gh OR gi -> gj +kk RSHIFT 1 -> ld +hz RSHIFT 5 -> ic +as RSHIFT 2 -> at +NOT jy -> jz +1 AND am -> an +ci OR ct -> cu +hg AND hh -> hj +jq OR jw -> jx +v OR w -> x +la LSHIFT 15 -> le +dh AND dj -> dk +dp AND dr -> ds +jq AND jw -> jy +au OR av -> aw +NOT bf -> bg +z OR aa -> ab +ga AND gc -> gd +hz AND ik -> im +jt AND jv -> jw +z AND aa -> ac +jr OR js -> jt +hb LSHIFT 1 -> hv +hf OR hl -> hm +ib OR ic -> id +fq OR fr -> fs +cq AND cs -> ct +ia OR ig -> ih +dd OR do -> dp +d AND j -> l +ib AND ic -> ie +as RSHIFT 3 -> au +be AND bg -> bh +dd AND do -> dq +NOT l -> m +1 AND gd -> ge +y AND ae -> ag +fo AND fz -> gb +NOT ie -> if +e AND f -> h +x RSHIFT 3 -> z +y OR ae -> af +hf AND hl -> hn +NOT h -> i +NOT hn -> ho +he RSHIFT 5 -> hh diff --git a/2015/day07/main.go b/2015/day07/main.go new file mode 100644 index 0000000..2df4165 --- /dev/null +++ b/2015/day07/main.go @@ -0,0 +1,114 @@ +package main + +import ( + "fmt" + "io" + "log" + "strconv" + "strings" +) + +var wires map[string]uint16 + +func main() { + var input []string + var bldInput string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + if strings.HasSuffix(bldInput, "->") { + bldInput = bldInput + " " + readInp + input = append(input, bldInput) + bldInput = "" + continue + } + if len(bldInput) > 0 { + bldInput += " " + } + bldInput = bldInput + readInp + } + + wires = make(map[string]uint16) + var done bool + for !done { + for i := range input { + parsePts := strings.Split(input[i], " -> ") + inputs := parsePts[0] + output := parsePts[1] + if _, ok := getValue(output); ok { + // We've already done this one + continue + } + // What's up with these inputs? + inpParts := strings.Split(inputs, " ") + if len(inpParts) == 1 { + if val, ok := getValue(inpParts[0]); ok { + setValue(output, val) + } else { + continue + } + } else if len(inpParts) == 2 { + if val, ok := getValue(inpParts[1]); ok { + setValue(output, ^val) + } else { + continue + } + } else { + // All other gates + var inp1, inp2 uint16 + if val, ok := getValue(inpParts[0]); ok { + inp1 = val + } else { + continue + } + if val, ok := getValue(inpParts[2]); ok { + inp2 = val + } else { + continue + } + + if inpParts[1] == "RSHIFT" { + setValue(output, (inp1 >> inp2)) + } else if inpParts[1] == "LSHIFT" { + setValue(output, (inp1 << inp2)) + } else if inpParts[1] == "OR" { + setValue(output, (inp1 | inp2)) + } else if inpParts[1] == "AND" { + setValue(output, (inp1 & inp2)) + } + } + if len(wires) == len(input) { + done = true + } + } + + if aWire, ok := wires["a"]; ok { + fmt.Printf("\"a\" value: %d\n", aWire) + done = true + } + } +} + +func setValue(key string, val uint16) { + wires[key] = val +} + +func getValue(input string) (uint16, bool) { + var ret uint16 + var i int + var err error + if i, err = strconv.Atoi(input); err != nil { + if w, ok := wires[input]; ok { + return w, true + } + return wires[input], false + } + ret = uint16(i) + return ret, true +} \ No newline at end of file diff --git a/2015/day07/problem b/2015/day07/problem new file mode 100644 index 0000000..3d61605 --- /dev/null +++ b/2015/day07/problem @@ -0,0 +1,103 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 7: Some Assembly Required --- + + This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! + Unfortunately, little Bobby is a little under the recommended age range, and he needs help + assembling the circuit. + + Each wire has an identifier (some lowercase letters) and can carry a 16-bit signal (a number + from 0 to 65535). A signal is provided to each wire by a gate, another wire, or some specific + value. Each wire can only get a signal from one source, but can provide its signal to multiple + destinations. A gate provides no signal until all of its inputs have a signal. + + The included instructions booklet describes how to connect the parts together: x AND y -> z + means to connect wires x and y to an AND gate, and then connect its output to wire z. + + For example: + + • 123 -> x means that the signal 123 is provided to wire x. + • x AND y -> z means that the bitwise AND of wire x and wire y is provided to wire z. + • p LSHIFT 2 -> q means that the value from wire p is left-shifted by 2 and then provided to + wire q. + • NOT e -> f means that the bitwise complement of the value from wire e is provided to wire + f. + + Other possible gates include OR (bitwise OR) and RSHIFT (right-shift). If, for some reason, + you'd like to emulate the circuit instead, almost all programming languages (for example, C, + JavaScript, or Python) provide operators for these gates. + + For example, here is a simple circuit: + + 123 -> x + 456 -> y + x AND y -> d + x OR y -> e + x LSHIFT 2 -> f + y RSHIFT 2 -> g + NOT x -> h + NOT y -> i + + After it is run, these are the signals on the wires: + + d: 72 + e: 507 + f: 492 + g: 114 + h: 65412 + i: 65079 + x: 123 + y: 456 + + In little Bobby's kit's instructions booklet (provided as your puzzle input), what signal is + ultimately provided to wire a? + + Your puzzle answer was 16076. + +--- Part Two --- + + Now, take the signal you got on wire a, override wire b to that signal, and reset the other + wires (including wire a). What new signal is ultimately provided to wire a? + + Your puzzle answer was 2797. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Bitwise_operation + . https://en.wikipedia.org/wiki/16-bit + . https://en.wikipedia.org/wiki/Bitwise_operation#AND + . https://en.wikipedia.org/wiki/Logical_shift + . https://en.wikipedia.org/wiki/Bitwise_operation#NOT + . https://en.wikipedia.org/wiki/Bitwise_operation#OR + . https://en.wikipedia.org/wiki/Logical_shift + . https://en.wikipedia.org/wiki/Bitwise_operations_in_C + . https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators + . https://wiki.python.org/moin/BitwiseOperators + . http://adventofcode.com/ + . http://adventofcode.com/day/7/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Some+Assembly+Required%22+%2D+Day+7+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7&title=I%27ve+completed+%22Some+Assembly+Required%22+%2D+Day+7+%2D+Advent+of+Code diff --git a/2015/day08/input b/2015/day08/input new file mode 100644 index 0000000..94538e7 --- /dev/null +++ b/2015/day08/input @@ -0,0 +1,300 @@ +"qxfcsmh" +"ffsfyxbyuhqkpwatkjgudo" +"byc\x9dyxuafof\\\xa6uf\\axfozomj\\olh\x6a" +"jtqvz" +"uzezxa\"jgbmojtwyfbfguz" +"vqsremfk\x8fxiknektafj" +"wzntebpxnnt\"vqndz\"i\x47vvjqo\"" +"higvez\"k\"riewqk" +"dlkrbhbrlfrp\\damiauyucwhty" +"d\"" +"qlz" +"ku" +"yy\"\"uoao\"uripabop" +"saduyrntuswlnlkuppdro\\sicxosted" +"tj" +"zzphopswlwdhebwkxeurvizdv" +"xfoheirjoakrpofles\"nfu" +"q\xb7oh\"p\xce\"n" +"qeendp\"ercwgywdjeylxcv" +"dcmem" +"\"i\x13r\"l" +"ikso\xdcbvqnbrjduh\"uqudzki\xderwk" +"wfdsn" +"pwynglklryhtsqbno" +"hcoj\x63iccz\"v\"ttr" +"zf\x23\\hlj\\kkce\\d\\asy\"yyfestwcdxyfj" +"xs" +"m\"tvltapxdvtrxiy" +"bmud" +"k\"a" +"b\"oas" +"\"yexnjjupoqsxyqnquy\"uzfdvetqrc" +"vdw\xe3olxfgujaj" +"qomcxdnd\"\\cfoe\"" +"fpul" +"m\"avamefphkpv" +"vvdnb\\x\\uhnxfw\"dpubfkxfmeuhnxisd" +"hey\\" +"ldaeigghlfey" +"eure\"hoy\xa5iezjp\\tm" +"yygb\"twbj\\r\"\x10gmxuhmp\"" +"weirebp\x39mqonbtmfmd" +"ltuz\\hs\"e" +"ysvmpc" +"g\x8amjtt\"megl\"omsaihifwa" +"yimmm" +"iiyqfalh" +"cwknlaaf" +"q\x37feg\xc6s\"xx" +"uayrgeurgyp\\oi" +"xhug\"pt\"axugllbdiggzhvy" +"kdaarqmsjfx\xc3d" +"\"vkwla" +"d\"" +"tmroz\"bvfinxoe\\mum\"wmm" +"\"n\"bbswxne\\p\\yr\"qhwpdd" +"skzlkietklkqovjhvj\xfe" +"pbg\\pab\"bubqaf\"obzcwxwywbs\\dhtq" +"xxjidvqh\"lx\\wu\"ij" +"daef\x5fe\x5b\\kbeeb\x13qnydtboof" +"ogvazaqy\"j\x73" +"y" +"n\"tibetedldy\\gsamm\"nwu" +"wldkvgdtqulwkad" +"dpmxnj" +"twybw\"cdvf\"mjdajurokbce" +"ru\"\\lasij\"i" +"roc\\vra\\lhrm" +"pbkt\x60booz\"fjlkc" +"j\x4dytvjwrzt" +"\\uiwjkniumxcs" +"cbhm\"nexccior\"v\"j\"nazxilmfp\x47" +"qdxngevzrlgoq" +"\"lrzxftytpobsdfyrtdqpjbpuwmm\x9e" +"mdag\x0asnck\xc2ggj\"slb\"fjy" +"wyqkhjuazdtcgkcxvjkpnjdae" +"aixfk\xc0iom\x21vueob" +"dkiiakyjpkffqlluhaetires" +"ysspv\"lysgkvnmwbbsy" +"gy\"ryexcjjxdm\"xswssgtr" +"s" +"ddxv" +"qwt\"\x27puilb\"pslmbrsxhrz" +"qdg\xc9e\\qwtknlvkol\x54oqvmchn\\" +"lvo" +"b" +"fk\"aa\"\"yenwch\\\\on" +"srig\x63hpwaavs\\\x80qzk\"xa\"\xe6u\\wr" +"yxjxuj\"ghyhhxfj\"\xa6qvatre" +"yoktqxjxkzrklkoeroil" +"\"jfmik\"" +"smgseztzdwldikbqrh\"" +"jftahgctf\"hoqy" +"tcnhicr\"znpgckt\"ble" +"vqktnkodh\"lo\"a\\bkmdjqqnsqr" +"ztnirfzqq" +"s" +"xx" +"iqj\"y\\hqgzflwrdsusasekyrxbp\\ad" +"\\xzjhlaiynkioz\"\"bxepzimvgwt" +"s\x36rbw" +"mniieztwrisvdx" +"atyfxioy\x2b\\" +"irde\x85\x5cvbah\\jekw\"ia" +"bdmftlhkwrprmpat\"prfaocvp" +"w\\k" +"umbpausy" +"zfauhpsangy" +"p\"zqyw" +"wtztypyqvnnxzvlvipnq\"zu" +"deicgwq\\oqvajpbov\\or\"kgplwu" +"mbzlfgpi\\\\zqcidjpzqdzxityxa" +"lfkxvhma" +"\xf2yduqzqr\"\\fak\"p\"n" +"mpajacfuxotonpadvng" +"anb\\telzvcdu\\a\xf2flfq" +"lrs\"ebethwpmuuc\"\x86ygr" +"qmvdbhtumzc\"ci" +"meet" +"yopg\x0fdxdq\"h\\ugsu\xffmolxjv" +"uhy" +"fzgidrtzycsireghazscvmwcfmw\\t" +"cqohkhpgvpru" +"bihyigtnvmevx\"xx" +"xz" +"zofomwotzuxsjk\"q\"mc\"js\"dnmalhxd" +"\\ktnddux\\fqvt\"ibnjntjcbn" +"ia" +"htjadnefwetyp\xd5kbrwfycbyy" +"\"\\hkuxqddnao" +"meqqsz\x83luecpgaem" +"cvks\x87frvxo\"svqivqsdpgwhukmju" +"sgmxiai\\o\"riufxwjfigr\xdf" +"fgywdfecqufccpcdn" +"faghjoq\x28abxnpxj" +"zuppgzcfb\"dctvp\"elup\"zxkopx" +"xqs\x45xxdqcihbwghmzoa" +"anbnlp\\cgcvm\"hc" +"xf\"fgrngwzys" +"nrxsjduedcy\x24" +"\x71sxl\"gj\"sds\"ulcruguz\\t\\ssvjcwhi" +"jhj\"msch" +"qpovolktfwyiuyicbfeeju\x01" +"nkyxmb\"qyqultgt\"nmvzvvnxnb" +"ycsrkbstgzqb\"uv\\cisn" +"s" +"ueptjnn\"\"sh" +"lp\"z\"d\"mxtxiy" +"yzjtvockdnvbubqabjourf\"k\"uoxwle" +"\x82\"wqm\"" +"\xb5cwtuks\x5fpgh" +"wd" +"tbvf" +"ttbmzdgn" +"vfpiyfdejyrlbgcdtwzbnm" +"uc" +"otdcmhpjagqix" +"\\\xb1qso\"s" +"scowax" +"behpstjdh\xccqlgnqjyz\"eesn" +"r\xe1cbnjwzveoomkzlo\\kxlfouhm" +"jgrl" +"kzqs\\r" +"ctscb\x7fthwkdyko\"\x62pkf\"d\xe6knmhurg" +"tc\"kw\x3ftt" +"bxb\x5ccl" +"jyrmfbphsldwpq" +"jylpvysl\"\"juducjg" +"en\\m\"kxpq\"wpb\\\"" +"madouht\"bmdwvnyqvpnawiphgac\"" +"vuxpk\"ltucrw" +"aae\x60arr" +"ttitnne\"kilkrgssnr\xfdurzh" +"oalw" +"pc\"\"gktkdykzbdpkwigucqni\"nxiqx" +"dbrsaj" +"bgzsowyxcbrvhtvekhsh\"qgd" +"kudfemvk\"\"\"hkbrbil\"chkqoa" +"zjzgj\\ekbhyfzufy" +"\\acos\"fqekuxqzxbmkbnn\x1ejzwrm" +"elxahvudn\"txtmomotgw" +"\x2eoxmwdhelpr\"cgi\xf7pzvb" +"eapheklx" +"hfvma\"mietvc\"tszbbm\"czex" +"h\"iiockj\\\xc1et" +"d\"rmjjftm" +"qlvhdcbqtyrhlc\\" +"yy\"rsucjtulm\"coryri\"eqjlbmk" +"tv" +"r\"bfuht\\jjgujp\"" +"kukxvuauamtdosngdjlkauylttaokaj" +"srgost\"\"rbkcqtlccu\x65ohjptstrjkzy" +"yxwxl\\yjilwwxffrjjuazmzjs" +"dxlw\\fkstu\"hjrtiafhyuoh\"sewabne" +"\x88sj\"v" +"rfzprz\xec\"oxqclu\"krzefp\\q" +"cfmhdbjuhrcymgxpylllyvpni" +"ucrmjvmimmcq\x88\xd9\"lz" +"lujtt\"" +"gvbqoixn\"pmledpjmo\"flydnwkfxllf" +"dvxqlbshhmelsk\x8big\"l" +"mx\x54lma\x8bbguxejg" +"\x66jdati\xeceieo" +"\"iyyupixei\x54ff" +"xohzf\"rbxsoksxamiu" +"vlhthspeshzbppa\x4drhqnohjop\"\"mfjd" +"f\"tvxxla\"vurian\"\"idjq\x3aptm\xc3olep" +"gzqz" +"kbq\\wogye\\altvi\\hbvmodny" +"j\xd8" +"ofjozdhkblvndl" +"hbitoupimbawimxlxqze" +"ypeleimnme" +"xfwdrzsc\\oxqamawyizvi\\y" +"enoikppx\xa1ixe\"yo\"gumye" +"fb" +"vzf" +"zxidr" +"cu\x31beirsywtskq" +"lxpjbvqzztafwezd" +"\\jyxeuo\x18bv" +"b\"vawc\"p\\\\giern\"b" +"odizunx\"\"t\\yicdn\"x\"sdiz" +"\"\"tebrtsi" +"ctyzsxv\xa6pegfkwsi\"tgyltaakytccb" +"htxwbofchvmzbppycccliyik\xe5a" +"ggsslefamsklezqkrd" +"rcep\"fnimwvvdx\"l" +"zyrzlqmd\x12egvqs\\llqyie" +"\x07gsqyrr\\rcyhyspsvn" +"butg\"" +"gb" +"gywkoxf\"jsg\\wtopxvumirqxlwz" +"rj\"ir\"wldwveair\x2es\"dhjrdehbqnzl" +"ru\"elktnsbxufk\\ejufjfjlevt\\lrzd" +"\"widsvok" +"oy\"\x81nuesvw" +"ay" +"syticfac\x1cfjsivwlmy\"pumsqlqqzx" +"m" +"rjjkfh\x78cf\x2brgceg\"jmdyas\"\\xlv\xb6p" +"tmuvo\"\x3ffdqdovjmdmkgpstotojkv\"as" +"jd\\ojvynhxllfzzxvbn\"wrpphcvx" +"pz" +"\"twr" +"n\\hdzmxe\"mzjjeadlz" +"fb\"rprxuagvahjnri" +"rfmexmjjgh\\xrnmyvnatrvfruflaqjnd" +"obbbde\"co\"qr\"qpiwjgqahqm\\jjp\"" +"vpbq\"\"y\"czk\\b\x52ed\"lnzepobp" +"syzeajzfarplydipny\"y\"\xe8ad" +"mpyodwb" +"\x47rakphlqqptd" +"wa\"oj\"aiy" +"a" +"ropozx" +"q\x51nbtlwa" +"etukvgx\\jqxlkq" +"\"tp\"rah\"pg\"s\"bpdtes\\tkasdhqd" +"dn\"qqpkikadowssb\xcah\"dzpsf\\ect\"jdh" +"pxunovbbrrn\\vullyn\"bno\"\"\"myfxlp\"" +"qaixyazuryvkmoulhcqaotegfj\\mpzm" +"bvfrbicutzbjwn\\oml\"cf\"d\"ezcpv\"j" +"rmbrdtneudemigdhelmb" +"aq\\aurmbhy" +"wujqvzw" +"gf\"tssmvm\"gm\"hu\x9a\xb7yjawsa" +"hrhqqxow\xe2gsydtdspcfqy\"zw\\ou" +"ianwwf\\yko\\tdujhhqdi" +"xylz\"zpvpab" +"lwuopbeeegp" +"aoop\x49jhhcexdmdtun" +"\\\\mouqqcsgmz" +"tltuvwhveau\x43b\"ymxjlcgiymcynwt" +"gsugerumpyuhtjljbhrdyoj" +"lnjm\xb8wg\"ajh" +"zmspue\"nfttdon\\b\"eww" +"\"w\x67jwaq\x7ernmyvs\\rmdsuwydsd\"th" +"ogtgvtlmcvgllyv" +"z\"fqi\"rvddoehrciyl" +"yustxxtot\"muec\"xvfdbzunzvveq" +"mqslw" +"txqnyvzmibqgjs\xb6xy\x86nfalfyx" +"kzhehlmkholov" +"plpmywcnirrjutjguosh\\" +"pydbnqofv\"dn\\m" +"aegqof" +"eambmxt\\dxagoogl\\zapfwwlmk" +"afbmqitxxqhddlozuxcpjxgh" +"vgts" +"bfdpqtoxzzhmzcilehnflna" +"s\"idpz" +"\xcfhgly\"nlmztwybx\"ecezmsxaqw" +"aackfgndqcqiy" +"\x22unqdlsrvgzfaohoffgxzfpir\"s" +"abh\"ydv\"kbpdhrerl" +"bdzpg" +"ekwgkywtmzp" +"wtoodejqmrrgslhvnk\"pi\"ldnogpth" +"njro\x68qgbx\xe4af\"\\suan" diff --git a/2015/day08/main.go b/2015/day08/main.go new file mode 100644 index 0000000..569447e --- /dev/null +++ b/2015/day08/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "fmt" + "io" + "log" + "strings" +) + +func main() { + var input []string + var readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + input = append(input, readInp) + } + + var codeCount int + var stringCount int + for i := range input { + codeCount += len(input[i]) + var skipChars int + fmt.Printf("%s -> %d\n", input[i], len(input[i])) + tmpInput := strings.Replace(input[i], "\\\"", "\"", -1) + fmt.Printf("%s -> %d\n", tmpInput, len(tmpInput)) + tmpInput = strings.Replace(tmpInput, "\\\\", "\\", -1) + fmt.Printf("%s -> %d\n", tmpInput, len(tmpInput)) + tmpInput = strings.TrimSuffix(strings.TrimPrefix(tmpInput, "\""), "\"") + fmt.Printf("%s -> %d\n", tmpInput, len(tmpInput)) + // Now search for hex sequences + for j := range tmpInput { + if len(tmpInput) > j+3 { + if tmpInput[j] == '\\' && tmpInput[j+1] == 'x' { + skipChars += 3 + } + } + } + fmt.Printf("Minus %d for hex\n", skipChars) + stringCount += len(tmpInput) - skipChars + } + fmt.Printf("Code: %d, String: %d\n", codeCount, stringCount) + fmt.Printf("Difference: %d\n", (codeCount - stringCount)) +} \ No newline at end of file diff --git a/2015/day08/problem b/2015/day08/problem new file mode 100644 index 0000000..6f4ea4e --- /dev/null +++ b/2015/day08/problem @@ -0,0 +1,95 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 8: Matchsticks --- + + Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital + copy. He needs to know how much space it will take up when stored. + + It is common in many programming languages to provide a way to escape special characters in + strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in + very similar ways. + + However, it is important to realize the difference between the number of characters in the code + representation of the string literal and the number of characters in the in-memory string + itself. + + For example: + + • "" is 2 characters of code (the two double quotes), but the string contains zero + characters. + • "abc" is 5 characters of code, but 3 characters in the string data. + • "aaa\"aaa" is 10 characters of code, but the string itself contains six "a" characters and + a single, escaped quote character, for a total of 7 characters in the string data. + • "\x27" is 6 characters of code, but the string itself contains just one - an apostrophe + ('), escaped using hexadecimal notation. + + Santa's list is a file that contains many double-quoted string literals, one on each line. The + only escape sequences used are \\ (which represents a single backslash), \" (which represents a + lone double-quote character), and \x plus two hexadecimal characters (which represents a single + character with that ASCII code). + + Disregarding the whitespace in the file, what is the number of characters of code for string + literals minus the number of characters in memory for the values of the strings in total for + the entire file? + + For example, given the four strings above, the total number of characters of string code (2 + 5 + + 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 + = 11) is 23 - 11 = 12. + + Your puzzle answer was 1350. + +--- Part Two --- + + Now, let's go the other way. In addition to finding the number of characters of code, you + should now encode each code representation as a new string and find the number of characters of + the new encoded representation, including the surrounding double quotes. + + For example: + + • "" encodes to "\"\"", an increase from 2 characters to 6. + • "abc" encodes to "\"abc\"", an increase from 5 characters to 9. + • "aaa\"aaa" encodes to "\"aaa\\\"aaa\"", an increase from 10 characters to 16. + • "\x27" encodes to "\"\\x27\"", an increase from 6 characters to 11. + + Your task is to find the total number of characters to represent the newly encoded strings + minus the number of characters of code in each original string literal. For example, for the + strings above, the total encoded length (6 + 9 + 16 + 11 = 42) minus the characters in the + original code representation (23, just like in the first part of this puzzle) is 42 - 23 = 19. + + Your puzzle answer was 2085. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Escape_sequences_in_C + . https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String + . http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators + . https://docs.python.org/2.0/ref/strings.html + . http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double + . http://adventofcode.com/ + . http://adventofcode.com/day/8/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Matchsticks%22+%2D+Day+8+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8&title=I%27ve+completed+%22Matchsticks%22+%2D+Day+8+%2D+Advent+of+Code diff --git a/2015/day09/day9 b/2015/day09/day9 new file mode 100644 index 0000000..2220198 Binary files /dev/null and b/2015/day09/day9 differ diff --git a/2015/day09/input b/2015/day09/input new file mode 100644 index 0000000..34175b9 --- /dev/null +++ b/2015/day09/input @@ -0,0 +1,28 @@ +Tristram to AlphaCentauri = 34 +Tristram to Snowdin = 100 +Tristram to Tambi = 63 +Tristram to Faerun = 108 +Tristram to Norrath = 111 +Tristram to Straylight = 89 +Tristram to Arbre = 132 +AlphaCentauri to Snowdin = 4 +AlphaCentauri to Tambi = 79 +AlphaCentauri to Faerun = 44 +AlphaCentauri to Norrath = 147 +AlphaCentauri to Straylight = 133 +AlphaCentauri to Arbre = 74 +Snowdin to Tambi = 105 +Snowdin to Faerun = 95 +Snowdin to Norrath = 48 +Snowdin to Straylight = 88 +Snowdin to Arbre = 7 +Tambi to Faerun = 68 +Tambi to Norrath = 134 +Tambi to Straylight = 107 +Tambi to Arbre = 40 +Faerun to Norrath = 11 +Faerun to Straylight = 66 +Faerun to Arbre = 144 +Norrath to Straylight = 115 +Norrath to Arbre = 135 +Straylight to Arbre = 127 \ No newline at end of file diff --git a/2015/day09/main.go b/2015/day09/main.go new file mode 100644 index 0000000..d451066 --- /dev/null +++ b/2015/day09/main.go @@ -0,0 +1,166 @@ +package main + +import ( + "fmt" + "io" + "log" + "os" + "strconv" + "strings" +) + +var allTowns map[string]roads + +type roads map[string]int + +func main() { + allTowns = make(map[string]roads) + var input []string + var readInp, bldInput string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + + if strings.HasSuffix(bldInput, "=") { + bldInput = bldInput + " " + readInp + input = append(input, bldInput) + bldInput = "" + continue + } + if len(bldInput) > 0 { + bldInput += " " + } + bldInput = bldInput + readInp + } + + for i := range input { + dirTowns := strings.Split(input[i], " to ") + secondPart := strings.Split(dirTowns[1], " = ") + town1 := dirTowns[0] + town2 := secondPart[0] + distance := mustAtoi(secondPart[1]) + buildRoute(town1, town2, distance) + } + + // All routes should be built, find the shortest + var shortestRoute []string + shortestDistance := -1 + for i := range allTowns { + var visited []string + lastVisit := i + tripDistance := 0 + for len(visited) < len(allTowns) { + var dist int + visited = append(visited, lastVisit) + lastVisit, dist = findShortest(lastVisit, visited) + if dist > 0 { + tripDistance += dist + } + } + if shortestDistance == -1 || tripDistance < shortestDistance { + shortestDistance = tripDistance + shortestRoute = visited + } + } + + // Now find the longest + var longestRoute []string + longestDistance := -1 + for i := range allTowns { + var visited []string + lastVisit := i + tripDistance := 0 + for len(visited) < len(allTowns) { + var dist int + visited = append(visited, lastVisit) + lastVisit, dist = findLongest(lastVisit, visited) + if dist > 0 { + tripDistance += dist + } + } + if longestDistance == -1 || tripDistance > longestDistance { + longestDistance = tripDistance + longestRoute = visited + } + } + + fmt.Println("Shortest Route:" + strconv.Itoa(shortestDistance)) + fmt.Println(strings.Join(shortestRoute, "->")) + fmt.Println("Longest Route:" + strconv.Itoa(longestDistance)) + fmt.Println(strings.Join(longestRoute, "->")) +} + +func findShortest(from string, exclude []string) (string, int) { + var toTown string + shortest := -1 + for j := range allTowns[from] { + var didIt bool + for ex := range exclude { + if j == exclude[ex] { + didIt = true + break + } + } + if didIt { + continue + } + // Find the quickest trip from here + if shortest == -1 || allTowns[from][j] < shortest { + shortest = allTowns[from][j] + toTown = j + } + } + return toTown, shortest +} + +func findLongest(from string, exclude []string) (string, int) { + var toTown string + longest := -1 + for j := range allTowns[from] { + var didIt bool + for ex := range exclude { + if j == exclude[ex] { + didIt = true + break + } + } + if didIt { + continue + } + // Find the longest trip from here + if longest == -1 || allTowns[from][j] > longest { + longest = allTowns[from][j] + toTown = j + } + } + return toTown, longest +} + +func mustAtoi(i string) int { + var ret int + var err error + if ret, err = strconv.Atoi(i); err != nil { + fmt.Println("Tried to mustAtoi: " + i) + os.Exit(1) + } + return ret +} + +func buildRoute(t1, t2 string, dist int) { + if _, ok := allTowns[t1]; !ok { + // Add this town + allTowns[t1] = make(map[string]int) + } + allTowns[t1][t2] = dist + // And the other direction + if _, ok := allTowns[t2]; !ok { + // Add this town + allTowns[t2] = make(map[string]int) + } + allTowns[t2][t1] = dist +} diff --git a/2015/day09/problem b/2015/day09/problem new file mode 100644 index 0000000..c34e75f --- /dev/null +++ b/2015/day09/problem @@ -0,0 +1,78 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 9: All in a Single Night --- + + Every year, Santa manages to deliver all of his presents in a single night. + + This year, however, he has some new locations to visit; his elves have provided him the + distances between every pair of locations. He can start and end at any two (different) + locations he wants, but he must visit each location exactly once. What is the shortest distance + he can travel to achieve this? + + For example, given the following distances: + + London to Dublin = 464 + London to Belfast = 518 + Dublin to Belfast = 141 + + The possible routes are therefore: + + Dublin -> London -> Belfast = 982 + London -> Dublin -> Belfast = 605 + London -> Belfast -> Dublin = 659 + Dublin -> Belfast -> London = 659 + Belfast -> Dublin -> London = 605 + Belfast -> London -> Dublin = 982 + + The shortest of these is London -> Dublin -> Belfast = 605, and so the answer is 605 in this + example. + + What is the distance of the shortest route? + + Your puzzle answer was 251. + +--- Part Two --- + + The next year, just to show off, Santa decides to take the route with the longest distance + instead. + + He can still start and end at any two (different) locations he wants, and he still must visit + each location exactly once. + + For example, given the distances above, the longest route would be 982 via (for example) Dublin + -> London -> Belfast. + + What is the distance of the longest route? + + Your puzzle answer was 898. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/9/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22All+in+a+Single+Night%22+%2D+Day+9+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9&title=I%27ve+completed+%22All+in+a+Single+Night%22+%2D+Day+9+%2D+Advent+of+Code diff --git a/2015/day10/input b/2015/day10/input new file mode 100644 index 0000000..89172ea --- /dev/null +++ b/2015/day10/input @@ -0,0 +1 @@ +1113122113 \ No newline at end of file diff --git a/2015/day10/main.go b/2015/day10/main.go new file mode 100644 index 0000000..821603b --- /dev/null +++ b/2015/day10/main.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +func printUsage() { + fmt.Println("Usage: day10 [iterations]") + os.Exit(1) +} + +/* Pt 2 Result: +Length of result: 5103798 +*/ +func main() { + var debugMode bool + + args := os.Args + if len(args) < 2 { + printUsage() + } + var lasString string + lasString = args[1] + + var iter int + var err error + if len(args) > 2 { + if iter, err = strconv.Atoi(args[2]); err != nil { + printUsage() + } + } else { + iter = 40 + } + if len(args) > 3 { + if args[2] == "--debug" { + debugMode = true + } + } + + fmt.Printf("Iterate %d times over %s\n", iter, lasString) + for i := 0; i < iter; i++ { + fmt.Print("O") + if i%10 == 9 { + fmt.Println(" " + strconv.Itoa(len(lasString))) + } + r := lookAndSay(lasString) + if debugMode { + fmt.Println(strconv.Itoa(i) + " >> " + r) + } + lasString = r + } + fmt.Println("\nLength of result: " + strconv.Itoa(len(lasString))) +} + +func lookAndSay(str string) string { + numI := 1 + var ret string + + strLen := len(str) + + for i := range str { + if strLen > i+1 { + if str[i+1] != str[i] { + ret += strconv.Itoa(numI) + string(str[i]) + numI = 0 + } + } else { + // Last char in string + ret += strconv.Itoa(numI) + string(str[i]) + } + numI++ + } + return ret +} \ No newline at end of file diff --git a/2015/day10/problem b/2015/day10/problem new file mode 100644 index 0000000..135cb11 --- /dev/null +++ b/2015/day10/problem @@ -0,0 +1,66 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 10: Elves Look, Elves Say --- + + Today, the Elves are playing a game called look-and-say. They take turns making sequences by + reading aloud the previous sequence and using that reading as the next sequence. For example, + 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s). + + Look-and-say sequences are generated iteratively, using the previous value as input for the + next step. For each step, take the previous value, and replace each run of digits (like 111) + with the number of digits (3) followed by the digit itself (1). + + For example: + + • 1 becomes 11 (1 copy of digit 1). + • 11 becomes 21 (2 copies of digit 1). + • 21 becomes 1211 (one 2 followed by one 1). + • 1211 becomes 111221 (one 1, one 2, and two 1s). + • 111221 becomes 312211 (three 1s, two 2s, and one 1). + + Starting with the digits in your puzzle input, apply this process 40 times. What is the length + of the result? + + Your puzzle answer was 360154. + +--- Part Two --- + + Neat, right? You might also enjoy hearing John Conway talking about this sequence (that's + Conway of Conway's Game of Life fame). + + Now, starting again with the digits in your puzzle input, apply this process 50 times. What is + the length of the new result? + + Your puzzle answer was 5103798. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + Your puzzle input was 1113122113. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Look-and-say_sequence + . https://www.youtube.com/watch?v=ea7lJkEhytA + . http://adventofcode.com/ + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Elves+Look%2C+Elves+Say%22+%2D+Day+10+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10&title=I%27ve+completed+%22Elves+Look%2C+Elves+Say%22+%2D+Day+10+%2D+Advent+of+Code diff --git a/2015/day11/input b/2015/day11/input new file mode 100644 index 0000000..664d9c6 --- /dev/null +++ b/2015/day11/input @@ -0,0 +1 @@ +hepxcrrq \ No newline at end of file diff --git a/2015/day11/main.go b/2015/day11/main.go new file mode 100644 index 0000000..3d04726 --- /dev/null +++ b/2015/day11/main.go @@ -0,0 +1,95 @@ +package main + +import ( + "fmt" + "os" + "strings" +) + +func printUsage() { + fmt.Println("Usage: day11 [add-amt]") + fmt.Println("If add-amt isn't given, we just add 1") + os.Exit(1) +} + +func main() { + args := os.Args + if len(args) < 2 { + printUsage() + } + var orig string + orig = args[1] + + var valid bool + for !valid { + orig = addOneToString(orig) + valid = testPassword(orig) + } + fmt.Println(orig) +} + +func addOneToString(s string) string { + lastPlace := s[len(s)-1] + ret := s[:len(s)-1] + if lastPlace == 'z' { + lastPlace = 'a' + ret = addOneToString(s[:len(s)-1]) + } else { + lastPlace++ + } + return ret + string(lastPlace) +} + +func testPassword(s string) bool { + if hasValidChars(s) && hasStraight(s) && hasDoubles(s) { + return true + } + return false +} + +// Test if string contains only valid chars +func hasValidChars(s string) bool { + if strings.Count(s, "i") > 0 { + return false + } + if strings.Count(s, "o") > 0 { + return false + } + if strings.Count(s, "l") > 0 { + return false + } + return true +} + +// Test if string has a 3 char straight +func hasStraight(s string) bool { + for i := range s { + if i > 1 { + if (s[i-2] == s[i]-2) && (s[i-1] == s[i]-1) { + return true + } + } + } + return false +} + +// Test if string has 2 doubles +func hasDoubles(s string) bool { + if i := hasDouble(s); i >= 0 { + return (hasDouble(s[i+2:]) >= 0) + } + return false +} + +// Returns index of first double in string +// -1 if there isn't one +func hasDouble(s string) int { + for i := range s { + if i > 0 { + if s[i-1] == s[i] { + return i - 1 + } + } + } + return -1 +} diff --git a/2015/day11/problem b/2015/day11/problem new file mode 100644 index 0000000..2b16b52 --- /dev/null +++ b/2015/day11/problem @@ -0,0 +1,75 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 11: Corporate Policy --- + + Santa's previous password expired, and he needs help choosing a new one. + + To help him remember his new password after the old one expires, Santa has devised a method of + coming up with a password based on the previous one. Corporate policy dictates that passwords + must be exactly eight lowercase letters (for security reasons), so he finds his new password by + incrementing his old password string repeatedly until it is valid. + + Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so on. Increase the + rightmost letter one step; if it was z, it wraps around to a, and repeat with the next letter + to the left until one doesn't wrap around. + + Unfortunately for Santa, a new Security-Elf recently started, and he has imposed some + additional password requirements: + + • Passwords must include one increasing straight of at least three letters, like abc, bcd, + cde, and so on, up to xyz. They cannot skip letters; abd doesn't count. + • Passwords may not contain the letters i, o, or l, as these letters can be mistaken for + other characters and are therefore confusing. + • Passwords must contain at least two different, non-overlapping pairs of letters, like aa, + bb, or zz. + + For example: + + • hijklmmn meets the first requirement (because it contains the straight hij) but fails the + second requirement requirement (because it contains i and l). + • abbceffg meets the third requirement (because it repeats bb and ff) but fails the first + requirement. + • abbcegjk fails the third requirement, because it only has one double letter (bb). + • The next password after abcdefgh is abcdffaa. + • The next password after ghijklmn is ghjaabcc, because you eventually skip all the passwords + that start with ghi..., since i is not allowed. + + Given Santa's current password (your puzzle input), what should his next password be? + + Your puzzle answer was hepxxyzz. + +--- Part Two --- + + Santa's password expired again. What's the next one? + + Your puzzle answer was heqaabcc. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + Your puzzle input was hepxcrrq. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Corporate+Policy%22+%2D+Day+11+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11&title=I%27ve+completed+%22Corporate+Policy%22+%2D+Day+11+%2D+Advent+of+Code diff --git a/2015/day12/input b/2015/day12/input new file mode 100644 index 0000000..bd91fda --- /dev/null +++ b/2015/day12/input @@ -0,0 +1 @@ +[["green",[{"e":"green","a":77,"d":{"c":"violet","a":"yellow","b":"violet"},"c":"yellow","h":"red","b":144,"g":{"a":["yellow",-48,72,87,{"e":"violet","c":123,"a":101,"b":87,"d":"red","f":88},{"e":"red","c":2,"a":1,"g":"blue","b":"green","d":"violet","f":170},"orange",171,162]},"f":"orange","i":"orange"},49,[{"c":{"e":"violet","a":-44,"d":115,"c":117,"h":194,"b":{"e":-17,"a":172,"d":"green","c":197,"h":53,"b":106,"g":"violet","f":-10},"g":"red","f":"orange"},"a":-49,"b":["violet","orange","blue"]}],"green"]],["orange"],{"e":"blue","a":["red","yellow"],"d":{"a":[{"c":{"a":181,"b":["orange",-40,"red","orange","yellow",31,60,71,"yellow"]},"a":[114,-40],"b":"orange"},["green",93,10,{"c":11,"a":170,"b":[161,-3],"d":-16},58,{"e":{"c":-2,"a":117,"b":"violet"},"c":["blue","yellow","red","violet","yellow",123,113],"a":"orange","g":19,"b":108,"d":"red","f":"yellow"},{"e":"green","c":"yellow","a":{"e":28,"c":"red","a":"violet","b":"red","d":"green"},"g":"yellow","b":116,"d":148,"f":"red"},[15],["green","green",43],"blue"],[133],"green",134,"violet",{"c":"red","a":[71,41,"blue"],"b":"yellow","d":"violet"},132,[10,"violet",[182,"green","green","orange"],78,{"c":"blue","a":[100,-36,"blue","violet",-10,"orange"],"b":{"e":"orange","c":"blue","a":160,"g":"green","b":190,"d":"red","f":186}},16],[{"c":"green","a":"violet","b":20,"d":"red"},"green","blue",{"c":[0,84,184,"orange",-34,"blue","orange",0,"violet","violet"],"a":10,"b":89},"green",182,127,-2,196]]},"c":-20,"h":[[165,[180,"yellow",-5,16,"red",[{"e":"orange","a":"orange","d":"orange","c":"yellow","h":"red","b":182,"g":21,"f":"violet"},"red",69,"violet",10,"red","orange"]],[160,"blue",{"e":"yellow","c":"violet","a":"green","g":43,"b":[-40,"yellow","yellow",118,57,"green","violet","yellow","violet"],"d":"yellow","f":"blue"}],130,{"e":["yellow",58,"green",139,"violet","red"],"c":"green","a":"green","g":{"e":163,"c":33,"a":15,"b":78,"d":"green"},"b":86,"d":"orange","f":58},"red","red",{"a":37}],"yellow",{"e":44,"a":{"a":136,"b":"yellow"},"d":"yellow","j":39,"c":[-28,["violet",{"e":"red","a":150,"d":189,"c":76,"h":"orange","b":"yellow","g":164,"f":"orange"}],{"e":12,"a":"red","d":"yellow","c":"yellow","h":102,"b":"yellow","g":"red","f":147},"violet",[40,"red",24,193,105,179,"violet","green",{"a":"yellow","b":"violet"}],39,-25,{"a":127},126,{"e":"red","c":151,"a":-46,"b":"green","d":"violet"}],"h":"red","b":122,"g":93,"f":["violet",{"c":102,"a":-16,"b":39,"d":176},"red",187,{"e":"blue","a":172,"d":{"a":-5},"c":25,"h":{"a":"red"},"b":"blue","g":["yellow","red"],"f":{"e":158,"c":85,"a":"blue","g":"green","b":"violet","d":125,"f":93},"i":11},"violet"],"i":[195,{"a":"blue"},48,[44,25,"green","red","violet",172,"orange",49]]},["yellow",[{"e":-4,"a":"red","d":"green","c":"blue","h":"green","b":"green","g":190,"f":30,"i":-2},"green","violet",{"e":92,"c":-11,"a":{"e":"orange","c":0,"a":47,"g":"blue","b":"orange","d":"yellow","f":-47},"b":40,"d":193},97,"violet",[51,168,"violet",{"c":-45,"a":167,"b":"orange"},"blue","orange",64],[188,"green",91,-10,66,"green"],"green","blue"],"green",-42,{"e":"red","c":"red","a":199,"g":84,"b":"blue","d":["blue",194,["green",88,110,-23,"yellow","green",15,"violet"]],"f":"red"}],{"e":"blue","c":-33,"a":-34,"b":"blue","d":81}],"b":{"e":"violet","c":165,"a":"violet","b":{"a":"red","b":"yellow"},"d":[6,71,"orange","orange",{"a":96},74,"yellow"]},"g":["yellow",["orange",[-27],[[[8,"red","blue",-46,62,"yellow",94],[60,"violet",141,"green"],16,"green","yellow","blue",81,[93,"red",183,"blue","red",30,-16,"red","red","yellow"],-21,139],{"c":"blue","a":"orange","b":"violet","d":51}],"blue","yellow",["violet",19,"orange","yellow","red","violet","blue","violet",{"e":"yellow","a":"violet","d":137,"c":"blue","h":197,"b":"orange","g":{"e":"yellow","c":"orange","a":18,"b":42,"d":183,"f":142},"f":68}],"green",["blue",85,"violet"]]],"f":"green"},[92,{"c":-26,"a":{"c":["orange","orange",{"e":131,"c":192,"a":-38,"g":16,"b":27,"d":"yellow","f":-46},120,"orange",-28,-18,3],"a":["red",-15,{"e":56,"c":-15,"a":150,"g":"blue","b":"orange","d":"violet","f":70},-44,{"e":"green","c":53,"a":"blue","b":"blue","d":-34,"f":"violet"},"orange",[161,"orange",-19,{"e":27,"c":98,"a":"violet","g":"yellow","b":-45,"d":191,"f":"green"}]],"b":-41,"d":[["orange","red","yellow",120,140],[{"e":-1,"c":"orange","a":"yellow","b":"yellow","d":86},42,[78,140,"orange","green","orange",-49,159],"yellow","red",90,{"c":"green","a":62,"b":"violet"}],"violet",178,30,"green",186]},"b":"red","d":"violet"},{"e":-21,"a":{"e":{"e":{"e":"orange","c":115,"a":199,"b":-43,"d":"yellow"},"a":"blue","d":"green","c":"blue","h":"violet","b":"red","g":"violet","f":{"a":5}},"a":[{"e":"green","a":[20,"yellow",23,100,"orange",142,"red",-3],"d":19,"c":18,"h":"blue","b":"yellow","g":"yellow","f":{"a":-33}}],"d":"yellow","j":"yellow","c":["red",-2,95,-1,"green","violet",12],"h":"orange","b":{"e":[94,-14,"orange",68],"c":["blue","yellow",[-12,"yellow",126,"orange",199,"red",133],{"e":-14,"a":40,"d":-48,"c":5,"h":"orange","b":"red","g":"yellow","f":"red","i":"orange"},"blue",[-35,87,84,"yellow"],"red","red",86,"yellow"],"a":11,"g":{"e":-34,"a":"orange","d":"blue","j":"blue","c":"yellow","h":"yellow","b":"violet","g":42,"f":188,"i":53},"b":"yellow","d":{"e":"red","c":84,"a":"violet","b":"orange","d":87},"f":["blue","yellow","red",{"c":"orange","a":"blue","b":61},"violet",20,-22,129]},"g":{"e":28,"c":170,"a":["green",98,"orange",150,"orange"],"b":"blue","d":"blue"},"f":"blue","i":[{"e":"green","a":"blue","d":19,"c":177,"h":-18,"b":{"e":-19,"a":"green","d":"yellow","c":172,"h":"red","b":"red","g":"yellow","f":"yellow"},"g":{"c":-36,"a":"red","b":"violet"},"f":121},141,"violet",113,81]},"d":{"e":133,"a":19,"d":-27,"c":{"c":["yellow"],"a":105,"b":{"a":"orange"},"d":{"e":"yellow","c":"orange","a":"orange","b":163,"d":"violet","f":"red"}},"h":"yellow","b":161,"g":110,"f":[[137,6,[195,"violet",179,93,"green",130,"blue","yellow"],70,"orange",-8,-28,"orange",{"e":59,"a":"red","d":128,"j":88,"c":"violet","h":188,"b":0,"g":0,"f":"green","i":2}],86,"green","orange",68,"yellow"]},"c":{"e":"violet","a":-49,"d":["blue",140],"c":-29,"h":["red",4,-45,165,["yellow","blue","blue"]],"b":"blue","g":{"e":{"e":{"e":"blue","c":168,"a":51,"b":-28,"d":"orange","f":"violet"},"c":"violet","a":"green","g":"blue","b":-29,"d":121,"f":69},"a":"violet","d":["orange",[12,192,"green",-17,160,"blue"],131,"blue",41,{"e":"violet","a":"green","d":"blue","c":182,"h":"red","b":10,"g":"blue","f":-37,"i":151},"blue"],"c":{"e":"orange","a":182,"d":155,"j":18,"c":-41,"h":119,"b":148,"g":"green","f":104,"i":141},"h":16,"b":"blue","g":[137],"f":"green","i":-35},"f":[["green","red",19,"yellow","blue","red"],["red",37,[36,"red",-38,183,"violet",-17,119,93],130,-20,77,[64,115,66,"green"]],-13,-23,"green",100,"orange",{"a":"orange","b":"red"}]},"h":["red",{"e":28,"c":{"c":"green","a":149,"b":["orange",137,"violet",184,"orange","green","red",20,72]},"a":114,"g":["blue",{"e":"yellow","a":104,"d":"red","c":-17,"h":"blue","b":"violet","g":"orange","f":"red","i":"red"},181,21,"blue","orange",111,{"e":39,"a":"orange","d":196,"j":119,"c":143,"h":-42,"b":"green","g":190,"f":-43,"i":37}],"b":"orange","d":{"e":["green",44,"green",177,"violet",-44,160,"violet",85,95],"a":{"e":138,"c":"yellow","a":"yellow","b":"blue","d":"green"},"d":"violet","j":"blue","c":100,"h":"blue","b":104,"g":-28,"f":189,"i":"orange"},"f":[121,{"c":110,"a":68,"b":5,"d":57},[108],15,"red",[83,"blue","green",-16,"yellow"],"green"]},[[80],160,68,187,"green","green",94,113,2,163],34,"orange",["yellow",{"e":72,"c":["green",11,"green","green","orange"],"a":{"c":"violet","a":13,"b":66,"d":36},"g":"blue","b":"yellow","d":140,"f":145},"red",53,-11,"yellow","blue",148,{"e":"violet","a":"violet","d":83,"c":"yellow","h":103,"b":-23,"g":36,"f":[154,"red",62,112,35],"i":"violet"}],{"e":174,"a":-49,"d":58,"j":114,"c":"violet","h":[162,"red",54,-8,[142,178,"red",26,"violet",71,-20,38,"orange"],"orange","yellow",[49,25,"violet","green","blue",189,"green","yellow",-25,55],"red"],"b":-13,"g":156,"f":[48,107,-15,167],"i":"blue"},["red",{"a":"red","b":"red"},"violet",[73,"blue","violet","red"],["red","red"],63,-12,108]],"b":{"c":"violet","a":{"a":-39,"b":166},"b":183},"g":36,"f":[45,"yellow","blue","violet",26,7,[[156,-18,"yellow"],-4,-37,[129,-11,["yellow",179,"violet","red","yellow","violet"],"red","red",133],17,"green",137,"red",-9,"yellow"],"yellow",[{"e":"green","a":"yellow","d":52,"c":127,"h":132,"b":38,"g":"yellow","f":"violet","i":"red"},"yellow","red",{"e":{"c":60,"a":126,"b":88},"a":159,"d":"red","j":70,"c":23,"h":195,"b":178,"g":"red","f":"yellow","i":"blue"},13,-37,[196,146,145,"orange",60,"violet",["red",144,51,"red",-26,172,"yellow","red",52,"yellow"],157,"green"],[{"a":-7,"b":"red"},123,{"e":"yellow","c":"orange","a":"orange","b":40,"d":"blue"},139,"green","red",48,{"e":165,"a":60,"d":83,"c":"yellow","h":186,"b":34,"g":"blue","f":178,"i":33},[116,"yellow",179,18,32]],"red"]]},{"c":[6,{"e":{"c":79,"a":82,"b":"orange"},"a":"blue","d":[38,"red",37,[12,134,139,"violet",102,60,"green",82,91],"orange",84],"j":"orange","c":["yellow","green","blue","violet",{"e":"orange","c":157,"a":"green","b":"blue","d":"violet","f":"blue"},64,["violet",176,-7,137,"red",57,"yellow"],"yellow",["blue",170,159],"orange"],"h":170,"b":[3],"g":"violet","f":"violet","i":186},{"e":{"e":"yellow","c":"red","a":"blue","g":["violet",104],"b":124,"d":42,"f":"violet"},"c":-43,"a":-28,"b":[6],"d":[0,97,{"e":-9,"a":"violet","d":31,"c":23,"h":40,"b":76,"g":"red","f":94},["violet"],124,68,"green",37]},[84,{"e":"yellow","c":18,"a":"orange","b":"blue","d":"red"},["yellow",66],81,"orange",-22,-10,"green",139],"red","yellow"],"a":25,"b":"yellow"},[{"e":25,"a":{"e":["violet",22,103,{"e":193,"c":"red","a":"yellow","g":"violet","b":"yellow","d":-33,"f":29},{"e":-10,"a":77,"d":"blue","c":-15,"h":74,"b":-4,"g":"orange","f":153},"yellow",176,94,"green",141],"c":"blue","a":146,"b":-26,"d":-7,"f":149},"d":"green","c":["violet"],"h":"orange","b":[[23,"violet","blue","violet","violet",-40],"orange","yellow"],"g":57,"f":[{"e":141,"a":"yellow","d":"red","c":138,"h":118,"b":{"a":"yellow","b":"red"},"g":133,"f":{"e":169,"c":"violet","a":"green","g":193,"b":"orange","d":"violet","f":-17},"i":"yellow"},72,"green","violet",[106,"red","red","red","yellow",180,"orange",{"a":"green","b":"green"},111,"blue"],147],"i":-7},[[62,65,158,"blue",86,"yellow"],[71,[168,179,"yellow","red","green"],-7],"violet"],"violet",["yellow","red","blue","orange",78,47,{"c":"orange","a":"violet","b":152},[-37,"yellow"],-11,6]],"red",{"e":"red","a":"orange","d":{"e":"red","a":10,"d":"blue","c":{"c":"green","a":91,"b":"yellow","d":-28},"h":158,"b":[["orange"]],"g":"blue","f":[[137,157,50,10,"blue",-12,"violet",76,76,80],[164,46,"orange",-23,{"a":"green"},"yellow","green","green","yellow",48],47]},"j":{"e":["orange",{"e":191,"c":"orange","a":25,"g":"red","b":"yellow","d":148,"f":"orange"},-34,"orange","orange",-36],"a":[{"e":198,"a":["blue",80,121,36,102],"d":{"e":"green","a":"blue","d":76,"j":"red","c":127,"h":"yellow","b":"yellow","g":"yellow","f":163,"i":"red"},"c":"yellow","h":73,"b":"red","g":"green","f":"red"},"violet",{"e":133,"a":"blue","d":"green","j":3,"c":"violet","h":144,"b":25,"g":"green","f":102,"i":"green"},{"e":{"a":"violet","b":"green"},"a":"green","d":[86],"c":"green","h":3,"b":{"c":"orange","a":"orange","b":"yellow","d":193},"g":-34,"f":-35,"i":"green"}],"d":[{"e":"violet","a":"blue","d":{"c":79,"a":"red","b":0,"d":"violet"},"c":77,"h":"violet","b":"green","g":-47,"f":"green"},-49,90],"j":"blue","c":"yellow","h":["violet","green",28,"green",97,"orange"],"b":53,"g":{"e":21,"a":{"c":42,"a":"blue","b":"red"},"d":"violet","c":142,"h":158,"b":"blue","g":["orange",197,"blue","green","yellow",-3,15,-38],"f":62},"f":{"a":32},"i":79},"c":{"e":[{"e":[125,"yellow",-43,"orange","red"],"c":3,"a":"orange","b":"orange","d":{"e":195,"c":16,"a":"yellow","b":94,"d":-20,"f":-13},"f":"yellow"},89,["orange"],"violet"],"c":{"e":"red","a":"orange","d":5,"j":{"a":92,"b":142},"c":22,"h":"blue","b":"orange","g":{"a":[-13,199,"green",133,-41,-22,"orange",169],"b":[134,"blue"]},"f":183,"i":["green",-24,"violet"]},"a":116,"g":[{"e":57,"a":["blue",144,44,43,"orange",34,"yellow",126,"red"],"d":"green","c":"violet","h":"orange","b":"violet","g":"violet","f":[196,60],"i":-21},[168],["red","violet","yellow","green","yellow","green","blue",113,{"e":"orange","a":"red","d":-7,"c":-29,"h":"orange","b":-44,"g":"red","f":-32}],{"a":116},"blue"],"b":{"c":{"e":-41,"a":"orange","d":154,"c":"yellow","h":-12,"b":"yellow","g":"blue","f":"violet","i":105},"a":-23,"b":2},"d":161,"f":"orange"},"h":[187,{"c":"yellow","a":"orange","b":"orange","d":"red"},[[58,"blue"],[111,["yellow","green","green","violet","green"],"orange","blue",112,-45],31,"violet"]],"b":{"e":[[13,"blue",-19,"blue","yellow",144,23,17,110],"violet",{"c":"orange","a":"yellow","b":73,"d":"red"},9,115,"blue","violet","yellow","blue","green"],"a":[-9,"yellow","violet",183,"red",14,"blue",192,"yellow",165],"d":"blue","j":{"e":[86],"a":-14,"d":"yellow","j":"violet","c":"violet","h":{"e":85,"a":["red","yellow",114,111,129,37,71,"blue"],"d":"yellow","c":43,"h":11,"b":72,"g":128,"f":"red"},"b":11,"g":183,"f":34,"i":187},"c":122,"h":{"c":[93,132,"yellow","yellow",91],"a":"green","b":"orange"},"b":[{"e":"blue","a":"green","d":"blue","j":{"e":"orange","a":"violet","d":"orange","j":"yellow","c":"yellow","h":"orange","b":"green","g":"orange","f":"green","i":"green"},"c":186,"h":"yellow","b":145,"g":112,"f":"orange","i":"orange"},100,139,-11,{"e":103,"c":["green","red",-40,90,"violet","violet","yellow"],"a":140,"g":"red","b":"violet","d":"red","f":"blue"},{"c":-43,"a":"orange","b":66},"red",["red","orange",["blue",187],76,192,50,"yellow","violet"]],"g":38,"f":"blue","i":[129,[30,"green",157,92,181,176],{"e":"violet","a":127,"d":172,"j":"yellow","c":148,"h":171,"b":"yellow","g":{"e":115,"a":"red","d":48,"c":-12,"h":"blue","b":"orange","g":"red","f":78},"f":135,"i":79}]},"g":[[173,131,"yellow",193,162,"yellow"],[-5,{"e":[116,102,"orange","yellow"],"a":189,"d":136,"c":{"e":72,"a":"blue","d":-13,"j":"yellow","c":90,"h":"violet","b":169,"g":"orange","f":"blue","i":"blue"},"h":186,"b":"orange","g":"red","f":"orange"},{"e":-8,"a":-37,"d":104,"c":"violet","h":"orange","b":-31,"g":25,"f":168,"i":119},"green",32,[[197,"orange","violet"]],"yellow",{"e":["red",-16,"yellow"],"a":"blue","d":31,"c":"yellow","h":"red","b":"red","g":"violet","f":20,"i":"violet"},31,80],22,{"e":{"e":"red","a":125,"d":"yellow","j":111,"c":34,"h":193,"b":100,"g":"orange","f":31,"i":15},"c":{"e":75,"a":13,"d":-29,"c":["green"],"h":-46,"b":{"a":58},"g":100,"f":{"c":"violet","a":"red","b":-35},"i":["violet","green","orange","violet",183,0,-27,96]},"a":"red","b":[95,"orange","blue","green",170,{"e":3,"a":"blue","d":125,"j":-25,"c":10,"h":25,"b":"blue","g":182,"f":141,"i":27},["violet",7,76,-37,"red",59,"yellow",29]],"d":78,"f":88}],"f":["violet",72],"i":[96,["green","orange",63,"red",83,"yellow"],[{"e":"red","a":{"e":"orange","a":"green","d":183,"c":"orange","h":"yellow","b":146,"g":-1,"f":"red","i":"orange"},"d":"green","j":"red","c":"red","h":"yellow","b":"violet","g":-9,"f":182,"i":"red"},-49,17,"orange",187,-2,[178,"red","red",131,195,[94,-26,"blue","green",0,1,101]]],-25,14,"violet",{"c":"blue","a":"green","b":"orange"},198,-2]},9],[{"e":["green",177,[-38],{"e":"green","a":[147,"green",[56,93,"violet","red"],82,{"e":"blue","a":"orange","d":"red","c":30,"h":"blue","b":10,"g":"orange","f":"orange","i":82},193],"d":"violet","j":69,"c":"green","h":161,"b":-12,"g":{"e":125,"c":-33,"a":-42,"g":70,"b":{"c":81,"a":52,"b":"red","d":"violet"},"d":["violet"],"f":39},"f":["red","green",74,158,14],"i":"yellow"},[144,88,["yellow","violet",-1,"blue",109,[53,86,-36,91,"violet","green",59,15],171,"blue"]],185],"c":{"e":{"a":92},"a":67,"d":"violet","c":"blue","h":[71,"violet",25,154,{"e":16,"a":"red","d":"red","j":"violet","c":54,"h":"violet","b":160,"g":"orange","f":{"e":-47,"a":"green","d":"blue","c":56,"h":175,"b":118,"g":97,"f":"red"},"i":"yellow"},{"e":[107,"violet","violet","blue",-4,"blue","green",82,"red"],"c":{"e":"yellow","c":"violet","a":"orange","b":"blue","d":"green"},"a":172,"b":131,"d":"green","f":43},"red","green",["red","green","violet","violet",132,"green",153,195,-41,[128]]],"b":"yellow","g":"green","f":{"c":72,"a":{"c":"green","a":"violet","b":"green","d":180},"b":48,"d":["blue",70,60,"orange",139,183,"red","red",{"a":"red","b":123},"yellow"]},"i":[66,77,"green","violet",25,[193,"orange",78,"red",["violet","red",163,37,"yellow"]]]},"a":"red","b":175,"d":0,"f":[{"e":38,"a":"yellow","d":"violet","c":68,"h":{"e":"orange","c":129,"a":"blue","b":"green","d":106,"f":"orange"},"b":"red","g":"green","f":{"e":91,"c":46,"a":"blue","g":"red","b":"yellow","d":92,"f":"yellow"}},["green",65,150,86,"orange"],"green",{"c":"green","a":30,"b":"yellow"}]},["blue",70,143,{"a":"green","b":[{"e":83,"c":63,"a":-2,"g":{"e":"green","c":"orange","a":-46,"b":"yellow","d":"red"},"b":39,"d":"red","f":123},"orange",57,34,{"c":"yellow","a":{"c":"blue","a":"green","b":"blue"},"b":"orange","d":{"e":"blue","a":158,"d":"red","c":69,"h":122,"b":6,"g":93,"f":"yellow","i":163}},{"e":183,"c":99,"a":"orange","g":76,"b":42,"d":31,"f":118}]},{"e":31,"c":["orange",186,58,{"e":"violet","c":9,"a":115,"b":[115,"yellow",19,"violet","blue","yellow"],"d":106}],"a":{"e":"red","c":{"a":82,"b":180},"a":71,"b":"yellow","d":100},"g":{"c":68,"a":"red","b":{"a":"blue","b":70}},"b":"yellow","d":"violet","f":-4},"yellow",[{"a":"yellow"},[{"e":"violet","a":159,"d":"violet","c":"blue","h":{"a":195,"b":-16},"b":97,"g":74,"f":126,"i":83},-49,"orange","orange",20,{"e":-37,"c":82,"a":"blue","b":"yellow","d":"orange"},"violet","green",5],"blue",{"a":-2},{"e":-39,"c":"yellow","a":-3,"b":127,"d":[196]},{"c":"red","a":-1,"b":"orange","d":166},{"e":{"e":"red","a":97,"d":"orange","j":47,"c":84,"h":-36,"b":-5,"g":"red","f":"yellow","i":113},"c":55,"a":{"e":[13,108,137,"green","green",-9,71,-36,"orange","blue"],"a":"violet","d":95,"c":6,"h":125,"b":"orange","g":"orange","f":130},"b":-28,"d":[97,46,[-7,"violet",146,155,166,"orange","orange","yellow",148,"red"],"orange",40,"red"]}],[{"c":"violet","a":"yellow","b":64,"d":"orange"},{"e":{"e":"violet","c":"blue","a":{"e":"yellow","a":-41,"d":181,"c":101,"h":"orange","b":"orange","g":"blue","f":51},"g":-25,"b":"red","d":41,"f":1},"a":25,"d":{"e":"orange","a":"green","d":-9,"c":"orange","h":71,"b":"red","g":137,"f":133},"j":[["yellow",116],93,"orange","violet","blue",150,34],"c":66,"h":"violet","b":-49,"g":[60,194,[136,-37,160,"red","orange","red",179,"red"]],"f":[-24,"violet",35],"i":"blue"},{"e":92,"c":"blue","a":"red","b":"blue","d":"green"},"red",[126],96,"red",198],87],{"e":{"e":["orange","violet",{"e":"green","a":-42,"d":103,"c":["violet",-48,37,122,107,"orange","blue",97],"h":"blue","b":92,"g":"orange","f":0},"blue",197,-9,"yellow",{"a":["orange","blue",186,"blue","green","red","red",48,"red","green"],"b":195},121,"blue"],"a":96,"d":"orange","j":94,"c":66,"h":{"a":["violet"],"b":"orange"},"b":"violet","g":191,"f":{"e":"red","c":-32,"a":[149,[69,"green",84,25,"red"],"yellow","violet",4,"violet","green",69],"b":"blue","d":148,"f":111},"i":93},"a":[181],"d":{"e":{"e":{"e":"red","c":36,"a":143,"b":82,"d":11},"a":168,"d":"orange","j":-45,"c":159,"h":"red","b":{"e":120,"a":-37,"d":"green","c":"green","h":"red","b":59,"g":"violet","f":173},"g":166,"f":"orange","i":"yellow"},"a":158,"d":"green","c":126,"h":[[159,"violet","violet","green",101,"orange",141],"violet",122,"yellow","red",79],"b":13,"g":"red","f":{"a":"orange"},"i":{"a":89,"b":{"e":[-20,"green",6,58,18],"a":-17,"d":137,"c":[-25,"orange",95,"yellow","green"],"h":3,"b":"violet","g":26,"f":"green","i":168}}},"c":["orange",{"e":163,"a":{"a":6},"d":-25,"c":164,"h":[-47,"yellow","orange",[139,93,93,"yellow","violet","red",-12],"blue",-32,136,10],"b":"orange","g":"blue","f":174}],"h":["blue",-34,-29,{"e":"violet","a":3,"d":"green","j":"red","c":"orange","h":"green","b":"red","g":"green","f":124,"i":{"e":186,"c":"violet","a":168,"g":110,"b":[127,136,31,109,"blue","red","blue","violet",79,91],"d":"red","f":["violet",191,-15,-22]}}],"b":[124,{"e":-38,"a":{"a":"yellow"},"d":[130,{"c":158,"a":"blue","b":103,"d":197},-36,[153,-6,173,121,"yellow",94,168,"violet",77,-35],168,"red",{"e":-32,"a":"red","d":46,"c":82,"h":91,"b":"blue","g":"yellow","f":"orange","i":174},"green"],"j":[189,-43,41],"c":[185],"h":[182],"b":[139,"violet",-44],"g":"yellow","f":"red","i":["red",-18,"violet","red",31,"red",115,-49,["yellow","yellow","violet","blue","violet","violet"]]},143,"yellow",["violet","red",["blue","violet",{"a":-49},41,"orange","blue"],{"a":"orange"},[93,-8,"yellow",-39]],166,155,"red","violet","orange"],"g":"violet","f":"red","i":[85,126,{"e":{"e":"red","c":-42,"a":51,"b":"yellow","d":"red","f":{"e":130,"c":"violet","a":115,"g":"violet","b":-28,"d":-3,"f":"blue"}},"a":92,"d":114,"c":"violet","h":{"e":-41,"a":"red","d":57,"j":82,"c":"violet","h":"green","b":"red","g":2,"f":-20,"i":78},"b":"yellow","g":"violet","f":86,"i":67},147,146,-33,"blue","violet"]},{"e":[[{"a":174},21,"orange","green","blue",{"e":127,"c":{"c":0,"a":197,"b":"yellow"},"a":"blue","b":["yellow",153,9,"blue"],"d":136}],"blue"],"c":[{"c":"red","a":[-5,"green",["violet"],-47,19,173],"b":106,"d":"yellow"},182,[21,106,"violet",10,"green",20,"orange"],["green"],{"e":-25,"c":"blue","a":"violet","b":["red",27,"blue",21,193,"green",["green","green"]],"d":["orange"],"f":18},"yellow","yellow",{"e":{"e":"violet","a":"green","d":"violet","c":"red","h":171,"b":["red",149,"violet"],"g":"yellow","f":"blue","i":"green"},"c":[86,-30,"orange",56,123,"green"],"a":65,"b":[86,129,"yellow","blue",87,127,182],"d":4,"f":[-36,179,"red",-9,27,{"c":111,"a":178,"b":"yellow","d":25},"red","blue"]},[-3,5,["orange","blue"],70],"yellow"],"a":[{"e":{"c":-15,"a":"red","b":-18,"d":"green"},"a":-42,"d":{"c":-47,"a":"red","b":"green","d":"yellow"},"c":{"e":56,"a":"green","d":"yellow","c":"orange","h":"yellow","b":"blue","g":-35,"f":179,"i":"green"},"h":"blue","b":[35,153],"g":193,"f":{"e":{"e":37,"c":86,"a":"green","g":170,"b":"violet","d":"red","f":-33},"c":187,"a":16,"b":147,"d":19,"f":"red"},"i":88},"green","blue",{"e":{"e":"orange","a":"blue","d":"orange","c":150,"h":-12,"b":"green","g":"red","f":145,"i":"red"},"c":"red","a":"yellow","b":"yellow","d":"blue"},196,{"e":"green","c":186,"a":"green","g":-18,"b":"red","d":[102,"green","orange",[-6,160,128,"green","violet",48,"violet","yellow",50],"blue","green","orange",[199,59,20,15,126]],"f":[[120,"red",69],49,18,84,"red","green",["orange","blue",-31,"green","red",198,115]]},{"e":"yellow","a":196,"d":["orange",{"e":"violet","a":21,"d":"green","c":"red","h":"green","b":18,"g":48,"f":174,"i":"orange"},{"a":-1,"b":"green"},"green"],"c":106,"h":"blue","b":"blue","g":"yellow","f":{"e":-4,"a":61,"d":18,"c":122,"h":"green","b":84,"g":165,"f":"orange"}}],"b":[43,{"e":137,"c":"green","a":"green","b":75,"d":125}],"d":{"e":178,"c":[-21,[116,20,"yellow","blue",161,"orange","blue",30,{"c":181,"a":-30,"b":3}],"orange",-9,"orange",["violet","green",54],"orange",[-20,97,{"c":59,"a":115,"b":-48,"d":-22},28,{"e":59,"c":"green","a":"green","b":"yellow","d":"green","f":-27}],{"a":"violet"},{"e":"blue","c":50,"a":"orange","b":"yellow","d":"orange","f":{"a":"red","b":"green"}}],"a":"orange","b":134,"d":-3,"f":{"e":"violet","a":"orange","d":"green","c":80,"h":"red","b":[140],"g":"red","f":"red"}}},-47,[-28,{"a":[46,["blue",-45,172,193,"blue","green",-2],122,{"a":"green","b":92},-35,[136,[-8,127,20,91,45,"orange"],"green","orange",["orange","yellow",92,162,48,"orange","violet",197],"blue","orange",57,172],"green",135],"b":{"e":[173,{"e":89,"a":96,"d":"orange","c":"orange","h":"green","b":74,"g":"yellow","f":60,"i":135},-11,3,"blue","violet","blue"],"c":160,"a":"blue","b":60,"d":"green","f":"red"}},{"e":[12,"orange"],"c":{"e":45,"c":{"e":-26,"a":86,"d":"yellow","c":["yellow",128,180,135,102,186,"red",194,"green"],"h":"violet","b":{"c":90,"a":-47,"b":56},"g":"blue","f":"red","i":28},"a":71,"b":"violet","d":25},"a":182,"b":"green","d":111,"f":"violet"},{"c":[-21,{"e":[157,13,"red",180,"yellow","green","red",59],"c":-49,"a":82,"b":69,"d":{"e":"orange","a":"yellow","d":98,"j":60,"c":"red","h":199,"b":172,"g":120,"f":"yellow","i":98}},[53,[-23,"orange",135,102,165,170,172,"violet"],"yellow","blue","green",105,97],[74,"violet","orange",["yellow",56,"orange",81,"violet"],"orange",177,75,11],"blue","yellow","blue","red",["blue"]],"a":{"a":-36,"b":"orange"},"b":5,"d":"green"},179,-26,{"a":"green","b":[163,{"a":"orange","b":-35},{"e":180,"a":"blue","d":40,"j":"orange","c":"green","h":"orange","b":"orange","g":131,"f":53,"i":169}]}]],[[{"e":153,"c":"orange","a":"yellow","g":{"e":-4,"c":{"e":115,"c":"red","a":121,"b":151,"d":"red"},"a":"orange","b":194,"d":"orange"},"b":{"a":30},"d":["green",[31,["violet"],["orange",152,"yellow","red"],"yellow"],"violet",{"a":"violet"},171,"violet",{"c":"violet","a":"orange","b":"orange"},"green"],"f":{"e":"yellow","c":["green","red"],"a":"red","g":-17,"b":-3,"d":-42,"f":150}},"orange",{"c":["orange"],"a":"red","b":{"c":-32,"a":{"a":"blue","b":"orange"},"b":{"c":75,"a":{"e":"green","a":101,"d":-3,"j":"violet","c":56,"h":166,"b":192,"g":-5,"f":-22,"i":100},"b":"yellow"},"d":159},"d":{"e":"violet","a":"yellow","d":["green","orange","blue","green"],"j":"yellow","c":[23,"green","blue","yellow","violet","red"],"h":[149,-24,"red",152],"b":-12,"g":"red","f":89,"i":169}},[{"e":{"e":"violet","a":[124,"blue","orange","green",160],"d":113,"c":"red","h":"blue","b":["violet","red","violet",104],"g":85,"f":179,"i":{"e":"orange","a":"violet","d":"violet","j":"yellow","c":191,"h":"red","b":53,"g":-25,"f":"green","i":169}},"a":[147,120],"d":"green","j":["yellow",["yellow",108,"violet",114,"green",195,25,"green"],"green","orange"],"c":["orange",148,141,"yellow",32,-24],"h":124,"b":"orange","g":[121,"blue","red","violet",-18],"f":"violet","i":"red"},["violet","green",94,91,"blue"],{"c":[9,"violet",-18,69,"orange","orange",-24,"yellow","yellow"],"a":"yellow","b":150,"d":73}],110,["blue",-9,"blue","yellow",{"e":[163,45,67],"c":135,"a":50,"b":[43,26,18,120,"green","blue",10,"green",68,-2],"d":{"e":136,"a":15,"d":89,"c":[65,"green",108,122,"yellow","violet","yellow"],"h":"green","b":{"e":125,"a":21,"d":51,"c":153,"h":33,"b":158,"g":"blue","f":26,"i":"green"},"g":-33,"f":[-16,14,"red","red",126,"violet",-16]}},"red",{"e":120,"c":"red","a":{"e":"green","a":"yellow","d":18,"c":150,"h":185,"b":["yellow","red","violet",48,"violet","blue"],"g":"green","f":{"a":"yellow"}},"g":[12,"blue",168,"orange",{"a":"red"},168,"red"],"b":-2,"d":{"e":"violet","c":"yellow","a":86,"g":155,"b":3,"d":-24,"f":149},"f":"yellow"}],[{"c":"green","a":91,"b":"green"},[{"e":"red","c":98,"a":{"c":"red","a":-49,"b":176,"d":105},"b":"red","d":169,"f":"blue"},-46,"green","blue",-30,{"c":154,"a":72,"b":"yellow"},[161,85]],111,"blue",172,57,{"a":-23,"b":"green"},81,[160,["blue","green","green",157],137,["blue",["violet",162],[153,"yellow","orange","violet",127,"green",148,182,29,150],-33,168,"blue"],95]]],["yellow",132,{"c":16,"a":[113],"b":"red","d":{"e":"green","c":24,"a":{"a":"red"},"g":125,"b":["violet",2,101],"d":"green","f":132}},89],[{"e":"yellow","c":[68,"green",[160,146],175,"orange",185,"blue",[198,[179,"yellow","green",72,33,112,179,"violet",194,1]]],"a":["blue","violet",153,"blue",{"a":77,"b":"yellow"},-19,"yellow","green"],"b":"yellow","d":29,"f":{"c":"violet","a":"violet","b":-18}},"yellow",{"e":["violet","green",["red","red","blue",126,137,47,["blue","blue","green",102,"orange","yellow","green"],"red"],[["blue","orange",16,-2],"green","orange","yellow",27,150,0],{"e":62,"c":"yellow","a":"blue","b":94,"d":10,"f":31},[-47,{"e":"green","a":"yellow","d":197,"j":99,"c":"yellow","h":152,"b":"orange","g":85,"f":"green","i":"green"},174,"blue","green"],106],"c":["blue",118,[120,161,-41,["violet"],"violet","yellow"],"red"],"a":["orange","green","red",58,"green",5,178,191,-43],"b":62,"d":"violet"},{"e":97,"a":[["yellow",122,"orange","red",{"e":165,"c":"blue","a":63,"g":"violet","b":"blue","d":"yellow","f":77},[104,118,"green","red","orange",61]],{"c":124,"a":86,"b":"violet"},"yellow",{"e":[98,110,40,104,126,90,140,"blue",46],"a":-42,"d":[77,"green","red",-28,"blue",88,29,-9,-28],"j":-3,"c":"green","h":{"e":153,"c":45,"a":"green","g":127,"b":"red","d":183,"f":"orange"},"b":3,"g":0,"f":["blue","green",62,"red","yellow","green"],"i":"orange"},127,171,[118,[119,"blue"],15,87,"orange",{"e":-34,"c":"violet","a":18,"b":153,"d":37,"f":"red"}],"red"],"d":"red","c":["yellow","red","blue","red","violet","red",-13,179],"h":100,"b":{"e":"orange","a":48,"d":"red","c":{"e":"violet","a":"violet","d":"orange","c":["violet","yellow","blue","yellow"],"h":"red","b":"violet","g":149,"f":"green"},"h":"yellow","b":46,"g":"blue","f":184},"g":16,"f":36,"i":{"e":"green","a":-4,"d":{"c":{"e":"yellow","a":"blue","d":177,"j":"violet","c":"red","h":140,"b":131,"g":137,"f":53,"i":28},"a":16,"b":161},"c":48,"h":[53,7,[137,80,113,160,"blue",105]],"b":"blue","g":"orange","f":"green"}},"yellow",{"c":["orange",{"e":-11,"c":-36,"a":"green","b":"yellow","d":"yellow","f":{"a":186}},-4,170,"green","green",16,123],"a":-29,"b":{"c":"orange","a":"blue","b":"orange"}},{"c":[[161,"violet","blue"],"yellow","yellow",["red",22,["red",92,103,126,-13,67,"blue"],-21,136,"violet",[193]],"blue",-15],"a":{"e":179,"a":1,"d":"yellow","c":[92,15],"h":"orange","b":{"e":-6,"a":"violet","d":"yellow","j":155,"c":198,"h":-18,"b":14,"g":"blue","f":-39,"i":"orange"},"g":{"a":"yellow"},"f":"blue"},"b":87},"yellow",{"c":"blue","a":[{"e":"red","a":"blue","d":"orange","c":"orange","h":-27,"b":"yellow","g":47,"f":{"e":"violet","a":"green","d":185,"j":"orange","c":"violet","h":138,"b":-3,"g":"blue","f":"red","i":150}},{"e":75,"c":168,"a":[12,"blue","green"],"g":{"c":"blue","a":"green","b":107},"b":-36,"d":"orange","f":72},2,[120,"green",182,"yellow",-23,"red"],"green",{"e":"blue","a":"orange","d":"blue","c":157,"h":"green","b":58,"g":"blue","f":-39},"red","orange",32],"b":"violet"},{"e":178,"a":{"c":{"e":59,"a":186,"d":"orange","c":{"a":"violet"},"h":"green","b":198,"g":{"a":"blue","b":"blue"},"f":"orange","i":2},"a":"red","b":[95,130,"blue","violet",98]},"d":176,"c":-38,"h":["yellow",128,"green",39,74,"yellow",5],"b":"blue","g":"violet","f":"orange"}],{"a":{"e":135,"c":{"e":{"e":["orange",-44,81,-11,-1,47,"orange",-36],"c":10,"a":12,"b":"red","d":{"e":"violet","c":"violet","a":161,"b":192,"d":133},"f":77},"c":92,"a":"yellow","g":["blue"],"b":{"e":"violet","a":-48,"d":"orange","c":"blue","h":"orange","b":-40,"g":81,"f":77},"d":102,"f":"yellow"},"a":127,"b":"violet","d":{"e":130,"a":36,"d":148,"c":"yellow","h":117,"b":"orange","g":"orange","f":-19,"i":["green",{"e":"red","a":191,"d":159,"j":"violet","c":"red","h":147,"b":"blue","g":"red","f":"red","i":"green"},"blue",62]},"f":-5},"b":[["green",-36,62,"green","blue",{"c":"violet","a":{"a":-4},"b":"violet","d":88},{"e":"yellow","c":166,"a":["blue"],"g":50,"b":146,"d":"blue","f":142},"yellow"]]},["red","blue",{"e":{"a":-16},"a":[["violet",{"e":"blue","a":171,"d":"blue","c":"blue","h":"green","b":"green","g":"orange","f":"yellow"},186,"orange",195,87,"green",[67,158,"blue",23]],25],"d":[159,74],"c":-28,"h":{"e":-16,"a":"red","d":55,"c":158,"h":167,"b":"red","g":27,"f":{"e":"yellow","c":[34,"blue",-22,"orange"],"a":94,"b":-30,"d":["blue",133,39,102,"orange"]}},"b":119,"g":{"e":104,"c":90,"a":["orange","blue",158,-34,"violet"],"g":"green","b":33,"d":["violet",125,"yellow","yellow",117,["blue",25,"orange"],["red",193,-23,"red","green",146,173],"red","yellow",10],"f":50},"f":47,"i":{"e":[121,144,172,171,{"e":"green","a":9,"d":"violet","c":-33,"h":64,"b":-4,"g":45,"f":75}],"a":8,"d":{"c":68,"a":["yellow","red","green"],"b":"violet","d":9},"c":"blue","h":17,"b":199,"g":115,"f":[["green",108,113,"red",6,"violet","violet","green",57,"green"],"orange",177,"red",34,"blue","red"],"i":-25}},{"e":"blue","a":["orange","yellow",["violet",27,"violet",128,120,{"e":"green","a":"orange","d":"orange","j":"blue","c":"yellow","h":"yellow","b":"yellow","g":139,"f":132,"i":81},"blue","red",53],7,"orange","violet",{"c":"yellow","a":{"a":-11},"b":"orange","d":87},"violet"],"d":[{"a":175},[163,"orange",185],[-30,109,194,119,170,"green","violet","yellow",125,"red"],"blue",{"e":"green","c":152,"a":37,"b":"red","d":["orange"],"f":"orange"},69,"yellow",{"e":{"e":"yellow","c":"violet","a":144,"b":"yellow","d":141,"f":"blue"},"c":"blue","a":"green","g":"yellow","b":178,"d":"yellow","f":-8},"green",["green","orange",-42,"orange"]],"c":"red","h":54,"b":"orange","g":["green",2,146,-6,{"e":52,"a":"orange","d":"red","c":"yellow","h":141,"b":35,"g":{"e":"violet","a":"blue","d":"yellow","c":"blue","h":100,"b":119,"g":"blue","f":"yellow"},"f":136,"i":"yellow"},194,["yellow",139,"green",["blue",14,"green","blue","blue",119,"violet",-5],{"a":61,"b":"orange"},"violet"]],"f":20},{"c":"orange","a":{"e":135,"c":"violet","a":111,"g":{"a":"red","b":96},"b":186,"d":33,"f":127},"b":{"e":83,"a":"yellow","d":"orange","c":"blue","h":"orange","b":0,"g":"orange","f":164,"i":"blue"},"d":-28},-42,{"e":"green","c":{"e":-20,"c":"yellow","a":66,"b":156,"d":"violet"},"a":[-9,129],"g":74,"b":{"e":"violet","c":"green","a":[52,"blue",["green",-8,"green","green"],"red",188,43,"green",{"e":"orange","a":40,"d":-6,"c":"orange","h":93,"b":"green","g":103,"f":"red"}],"g":{"e":"red","c":"yellow","a":16,"b":7,"d":70},"b":{"e":133,"a":150,"d":{"a":34,"b":"green"},"j":166,"c":156,"h":79,"b":"red","g":178,"f":-37,"i":163},"d":"blue","f":"green"},"d":{"c":"blue","a":"violet","b":177,"d":80},"f":[61,88,"yellow",{"c":"blue","a":"orange","b":"violet","d":"yellow"},{"c":119,"a":"violet","b":{"a":"red"},"d":84},95,170]},{"e":191,"c":2,"a":"orange","b":{"a":[-9,"green","violet",["green",132,"red",61,85],3,2]},"d":["green","yellow","violet",-46,48,"green"]}],["violet",["yellow"],["blue",{"e":-15,"c":{"e":["green","violet",0,3,183,165,-1,"orange","blue"],"a":"violet","d":20,"c":"violet","h":"yellow","b":60,"g":"violet","f":163,"i":135},"a":71,"b":{"c":[115,"green",25,"yellow","blue",66],"a":"yellow","b":"green"},"d":"violet","f":{"e":"yellow","c":"blue","a":"blue","b":59,"d":[69,71,"yellow","red",99,"green","yellow",144,43,-38]}},"yellow","blue","orange",55,{"c":[-9,-16,"green",100,28,"red","blue","blue",174],"a":-31,"b":106,"d":"violet"},"blue"],[141,[32,"orange",{"c":-6,"a":-7,"b":64},["blue",{"e":-24,"c":"yellow","a":153,"b":"orange","d":"blue","f":"violet"},"violet",-28,197,"yellow","green","green"],2,{"e":"violet","c":"red","a":"red","b":"yellow","d":"yellow"},["yellow"],"red"],["green",[-16,47],"blue",87,"red","green"],105,"violet",[[127,"violet",81],"red","blue",[193,178,-6],20,"red",61],-2,"blue",-35],{"c":-12,"a":189,"b":"red"},[12,196,["red",27,["violet","green",15,["yellow","green",152,56,187,"yellow",69],"violet"]],127,{"a":"yellow"},-35,[[180,{"c":"yellow","a":191,"b":"violet","d":"red"},41,33,-5],188,"red","violet",23,100,30,91,-15],"blue"],[[129,"blue",{"a":"red"},"violet","green",56,["yellow"],180,[156,"violet"],-49],48,"red",38,{"a":{"e":93,"a":"yellow","d":170,"c":{"e":116,"a":5,"d":89,"j":"blue","c":"blue","h":"red","b":"blue","g":-2,"f":"red","i":-7},"h":148,"b":149,"g":"red","f":-18,"i":-44}},101,183],[25,16,123]],{"e":{"c":"orange","a":{"e":[{"c":"green","a":"orange","b":100,"d":-30}],"a":187,"d":"green","c":{"a":122},"h":-10,"b":118,"g":-12,"f":63},"b":{"e":["violet","yellow","yellow",167,163,5],"a":-28,"d":[-2,61,"red",-18,"red",{"e":"yellow","a":"orange","d":"yellow","j":"green","c":"orange","h":-10,"b":-32,"g":115,"f":141,"i":164},"red",["violet",99,"orange","blue","orange","green","green","violet","yellow"]],"c":-24,"h":"blue","b":"violet","g":47,"f":156},"d":195},"a":{"a":[176]},"d":["violet",[["green",180,"violet","yellow"],{"e":133,"a":"violet","d":{"e":57,"a":"yellow","d":57,"j":"violet","c":"red","h":33,"b":"green","g":"yellow","f":"green","i":79},"j":"orange","c":"violet","h":62,"b":"blue","g":-37,"f":"violet","i":93},-43,"violet",103,"yellow",194,56],{"e":-19,"c":"yellow","a":"orange","b":-19,"d":"red","f":"yellow"}],"c":162,"h":[73,"green",[87,{"a":"green"}],[56,"green",[["green",-2,"green",-47,"yellow",-39,47],"red",129,[90,181,50,"green","green","green","blue",7,"violet"],-3,9,-12,171],"red","orange",159,["violet","yellow",77,86,"yellow","yellow","red",185],145,[81,133]],"yellow",-3,[{"c":["orange",108,82],"a":"violet","b":{"a":"yellow","b":"yellow"},"d":42}],"orange",[-27,["green",{"c":"violet","a":"violet","b":"orange","d":15},78],"red",23],"orange"],"b":{"e":"yellow","a":46,"d":[118,31,142,{"e":-48,"a":"blue","d":"green","c":"violet","h":69,"b":"orange","g":178,"f":"orange","i":"green"},{"e":109,"a":"orange","d":-7,"c":42,"h":168,"b":"blue","g":157,"f":{"a":93,"b":142},"i":38},[59,80],"orange",73,"violet"],"c":122,"h":{"e":153,"c":"yellow","a":11,"b":"orange","d":101},"b":"blue","g":"orange","f":[{"e":48,"c":-39,"a":77,"g":-33,"b":"yellow","d":30,"f":36},153,{"c":"violet","a":78,"b":63,"d":"orange"},117],"i":"red"},"g":"yellow","f":{"a":"orange","b":[{"a":87},"violet","orange",96,154,"orange","violet",{"a":[-45],"b":103}]}},"red"],[{"e":"violet","a":{"e":167,"a":{"e":"orange","c":{"e":"red","c":76,"a":"green","b":"violet","d":146,"f":152},"a":"violet","b":-8,"d":76,"f":"red"},"d":[102,"yellow","blue","blue",22,73],"c":"red","h":{"e":{"c":92,"a":178,"b":{"e":-43,"a":"yellow","d":136,"j":"red","c":193,"h":98,"b":"orange","g":49,"f":"yellow","i":"violet"}},"a":54,"d":138,"j":[0,[177,178],"red",52,[87,"violet",123,"orange","orange","yellow",48,"yellow"],"violet",100,"blue"],"c":3,"h":"green","b":175,"g":{"e":[175,-25,-47,"orange",60,185],"a":["orange",-49,156],"d":"yellow","j":8,"c":-28,"h":129,"b":[89,-12,67,"green",195,"red","violet",150,"red",106],"g":"violet","f":-29,"i":123},"f":"orange","i":71},"b":[172,["yellow","violet","green","blue",194],-46,{"a":102,"b":"green"}],"g":[{"e":{"c":23,"a":"yellow","b":-25},"a":"blue","d":"green","j":185,"c":"yellow","h":["orange","violet",-21],"b":{"c":191,"a":197,"b":"yellow"},"g":115,"f":-41,"i":"blue"},-17,[-23,64,"red",8,"orange",[105,-11,29,-23,30,65,15],170],"yellow","yellow",-46,"green","orange",143],"f":177},"d":"red","c":"red","h":135,"b":{"e":"red","a":"orange","d":["violet",[23,"red","violet","orange",66,{"c":"orange","a":"green","b":169,"d":57},"blue",125,"green"],110,135,[-40,"violet","yellow",-26,-23,44],"orange",28],"c":"orange","h":107,"b":91,"g":105,"f":{"e":{"e":164,"c":180,"a":"blue","b":"yellow","d":144},"c":"violet","a":"violet","g":95,"b":"red","d":"violet","f":"green"},"i":156},"g":["violet",108,["blue","yellow","red",[23,"yellow",3,159,112],{"e":-41,"c":"green","a":22,"b":"violet","d":"blue","f":"blue"},"violet",-27,"green","violet",-17],"green",{"e":{"e":[-19,96,-28,"orange"],"c":"yellow","a":"yellow","g":124,"b":97,"d":{"a":"blue"},"f":"green"},"a":46,"d":["blue",118,"yellow","yellow","yellow","green",["yellow",-10,90,167,"red",54,-15]],"j":106,"c":"red","h":[{"e":"red","c":28,"a":"yellow","b":170,"d":"blue","f":105},-40,"orange",188,"yellow",142],"b":117,"g":"violet","f":{"a":[-5,"red",46,182,"red","orange"]},"i":"yellow"},["orange",88,18,{"e":"blue","a":"violet","d":"blue","c":"violet","h":"violet","b":196,"g":103,"f":67,"i":13}],"blue","blue"],"f":-19,"i":{"a":166}},164],[{"e":{"e":"blue","a":13,"d":{"e":{"e":"orange","a":88,"d":"red","c":"yellow","h":[93,79],"b":"orange","g":109,"f":34,"i":-13},"a":-44,"d":"red","j":[173,78,"red",{"e":"yellow","a":-32,"d":"blue","j":"violet","c":"blue","h":119,"b":"green","g":-30,"f":193,"i":95},"orange",-43,-16],"c":["green",{"e":41,"c":"red","a":109,"b":159,"d":59},173,18,"violet",21,"red"],"h":"blue","b":44,"g":{"a":129,"b":-10},"f":-26,"i":27},"j":"red","c":{"a":{"c":-28,"a":"green","b":188,"d":"blue"},"b":"blue"},"h":[183,[118,[-7,"orange"],132,[23,175,"yellow","green",11,178,171,"orange","blue",18],134,1,"green",[-9,99],103,-25],"red",[65,"red","blue"],"violet","blue"],"b":"yellow","g":164,"f":-9,"i":{"c":51,"a":"green","b":115,"d":{"a":27,"b":"red"}}},"a":[{"e":[143,"violet",128,"red","yellow",185,"green","red","red"],"a":29,"d":"red","c":170,"h":[131,"violet",96,{"a":"yellow","b":"green"},139,22,176,"yellow",[-46,-14,"red","blue",83,141],[132,108,"blue","blue","green",197,"yellow"]],"b":"blue","g":"orange","f":"yellow","i":[-9]},"violet",56,[169,12,155,["red",197,{"e":"violet","a":22,"d":"violet","c":84,"h":"red","b":70,"g":"violet","f":-41},47,"violet"],[["green","green",179,56,"green","violet",171,"violet","violet"],"blue","red","green",-17,"green",190],"green","red",146,60],"yellow","red","yellow","violet"],"d":[[141,40,"yellow",1,"blue","green","yellow",{"e":13,"a":"blue","d":"red","c":"red","h":176,"b":"violet","g":164,"f":4,"i":"violet"}]],"c":72,"h":15,"b":"yellow","g":{"e":[-12,"blue",["red","blue",11],29,{"e":59,"c":"red","a":{"e":55,"a":"blue","d":"orange","c":"yellow","h":"violet","b":-19,"g":"green","f":"violet","i":197},"b":"orange","d":"violet","f":90},[-14,154,"violet","orange",74,{"e":"yellow","a":"violet","d":66,"c":"yellow","h":80,"b":"yellow","g":"yellow","f":"orange","i":"blue"},"green","red",116,149],"green",108],"c":{"c":28,"a":"blue","b":"yellow","d":"blue"},"a":36,"b":["orange","green","orange","green","red",46,55,"blue",["violet",98,[163,-35,163,-28],"blue","red",155,"blue"],-8],"d":163},"f":[9,"green",{"c":"green","a":"violet","b":68,"d":"yellow"},114,33,1,-25]},["red",[-20,{"c":"yellow","a":"red","b":"green","d":{"a":"red"}},"red",[[141,76],[174],100,{"e":126,"c":39,"a":["violet",94,"orange",102,"blue"],"b":55,"d":"yellow","f":"yellow"},146,{"c":169,"a":"red","b":"red"},[["green",-48,"violet","orange"],[80,-7,-22,"yellow","orange","yellow",185,"orange"],"green","violet","orange"],"red"],"yellow"],[{"a":["orange","blue"],"b":[{"a":-42,"b":"violet"},"green",99,-20,"blue"]},{"c":"blue","a":"violet","b":14,"d":9},"green",{"c":["blue",148,[38,139,125,52,"red",40,190,"yellow",21,"violet"],"violet",110,"green"],"a":{"c":97,"a":[35,"orange",44,"red",87,"orange","blue",61,"yellow"],"b":176,"d":144},"b":137},85,[192,-37,"orange",{"c":"yellow","a":-10,"b":[71]},"yellow",176,["green",14],{"a":102},-39],"violet",164],-9,"blue",[["blue"],70]]]] diff --git a/2015/day12/main.go b/2015/day12/main.go new file mode 100644 index 0000000..4ceafc2 --- /dev/null +++ b/2015/day12/main.go @@ -0,0 +1,133 @@ +package main + +import ( + "fmt" + "io" + "log" + "os" + "regexp" + "strconv" + "strings" +) + +func main() { + var inpArr []string + var input, readInp string + for { + _, err := fmt.Scan(&readInp) + if err != nil { + if err != io.EOF { + log.Fatal(err) + } + break + } + inpArr = append(inpArr, readInp) + } + input = strings.Join(inpArr, "") + + //fmt.Println("Part 1 Solution: " + strconv.Itoa(sumAllInts(input))) + fmt.Println("Part 2 Solution: " + strconv.Itoa(sumAllInts(removeAllValue(input, "red")))) + //removeAllValue(input, "red") +} + +func removeAllValue(s string, remove string) string { + ret := s + var removed bool + //ret, _ = removeFirstValue(ret, remove) + ret, removed = removeFirstValue(ret, remove) + for removed { + ret, removed = removeFirstValue(ret, remove) + } + return ret +} + +// Not quite returning proper JSON... But may be good enough +// for the problem (since we're not looking for JSON output +// anyways +func removeFirstValue(s string, remove string) (string, bool) { + ret := s + var curlIdx []int + removeStart := -1 + for i := range s { + if s[i] == '{' { + curlIdx = pushLevel(curlIdx, i) + } + if checkForValueAtIdx(s, ":\""+remove+"\"", i) { + removeStart, curlIdx = popLevel(curlIdx) + ret = strings.Replace(ret, trimAtClose(s[removeStart:]), "", -1) + // Now figure out if we have an abandoned key + if ret[removeStart-1] == ':' { + // Trackback in ret until we find the matching " and remove up to removeStart + remTrackBack := removeStart - 3 + for ret[remTrackBack] != '"' { + remTrackBack-- + } + } + return ret, true + } + if s[i] == '}' { + _, curlIdx = popLevel(curlIdx) + } + } + return ret, false +} + +// Trim string after closing bracket/brace +func trimAtClose(s string) string { + var levelStack []int + for i := range s { + if s[i] == '[' || s[i] == '{' { + levelStack = pushLevel(levelStack, i) + } else if s[i] == ']' || s[i] == '}' { + idx := -1 + idx, levelStack = popLevel(levelStack) + if idx == 0 { + endIdx := i + 1 + if s[i+1] == ',' { + endIdx++ + } + return s[:endIdx] + } + } + } + return s +} + +// Checks if the s contains v starting at index i +func checkForValueAtIdx(s string, v string, i int) bool { + if len(s) > i+len(v) { + if s[i:i+len(v)] == v { + return true + } + } + return false +} + +// Simple Part 1 solution +func sumAllInts(s string) int { + var allIntStrings []string + re := regexp.MustCompile("[-]?[0-9]+") + allIntStrings = append(allIntStrings, re.FindAllString(s, -1)...) + var sum int + for i := range allIntStrings { + sum += mustAtoi(allIntStrings[i]) + } + return sum +} + +func pushLevel(stack []int, n int) []int { + return append(stack, n) +} + +func popLevel(stack []int) (int, []int) { + return stack[len(stack)-1], stack[:len(stack)-1] +} + +func mustAtoi(s string) int { + r, err := strconv.Atoi(s) + if err != nil { + fmt.Println("Tried to Atoi " + s) + os.Exit(1) + } + return r +} diff --git a/2015/day12/problem b/2015/day12/problem new file mode 100644 index 0000000..4943b8d --- /dev/null +++ b/2015/day12/problem @@ -0,0 +1,70 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 12: JSAbacusFramework.io --- + + Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, + their accounting software uses a peculiar storage format. That's where you come in. + + They have a JSON document which contains a variety of things: arrays ([1,2,3]), objects + ({"a":1, "b":2}), numbers, and strings. Your first job is to simply find all of the numbers + throughout the document and add them together. + + For example: + + • [1,2,3] and {"a":2,"b":4} both have a sum of 6. + • [[[3]]] and {"a":{"b":4},"c":-1} both have a sum of 3. + • {"a":[-1,1]} and [-1,{"a":1}] both have a sum of 0. + • [] and {} both have a sum of 0. + + You will not encounter any strings containing numbers. + + What is the sum of all numbers in the document? + + Your puzzle answer was 191164. + +--- Part Two --- + + Uh oh - the Accounting-Elves have realized that they double-counted everything red. + + Ignore any object (and all of its children) which has any property with the value "red". Do + this only for objects ({...}), not arrays ([...]). + + • [1,2,3] still has a sum of 6. + • [1,{"c":"red","b":2},3] now has a sum of 4, because the middle object is ignored. + • {"d":"red","e":[1,2,3,4],"f":5} now has a sum of 0, because the entire structure is + ignored. + • [1,"red",5] has a sum of 6, because "red" in an array has no effect. + + Your puzzle answer was 87842. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://json.org/ + . http://adventofcode.com/ + . http://adventofcode.com/day/12/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22JSAbacusFramework%2Eio%22+%2D+Day+12+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12&title=I%27ve+completed+%22JSAbacusFramework%2Eio%22+%2D+Day+12+%2D+Advent+of+Code diff --git a/2015/day13/input b/2015/day13/input new file mode 100644 index 0000000..a6f9c66 --- /dev/null +++ b/2015/day13/input @@ -0,0 +1,56 @@ +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. +Bob would gain 63 happiness units by sitting next to Eric. +Bob would gain 41 happiness units by sitting next to Frank. +Bob would gain 30 happiness units by sitting next to George. +Bob would gain 87 happiness units by sitting next to Mallory. +Carol would lose 35 happiness units by sitting next to Alice. +Carol would lose 99 happiness units by sitting next to Bob. +Carol would lose 51 happiness units by sitting next to David. +Carol would gain 95 happiness units by sitting next to Eric. +Carol would gain 90 happiness units by sitting next to Frank. +Carol would lose 16 happiness units by sitting next to George. +Carol would gain 94 happiness units by sitting next to Mallory. +David would gain 36 happiness units by sitting next to Alice. +David would lose 18 happiness units by sitting next to Bob. +David would lose 65 happiness units by sitting next to Carol. +David would lose 18 happiness units by sitting next to Eric. +David would lose 22 happiness units by sitting next to Frank. +David would gain 2 happiness units by sitting next to George. +David would gain 42 happiness units by sitting next to Mallory. +Eric would lose 65 happiness units by sitting next to Alice. +Eric would gain 24 happiness units by sitting next to Bob. +Eric would gain 100 happiness units by sitting next to Carol. +Eric would gain 51 happiness units by sitting next to David. +Eric would gain 21 happiness units by sitting next to Frank. +Eric would gain 55 happiness units by sitting next to George. +Eric would lose 44 happiness units by sitting next to Mallory. +Frank would lose 48 happiness units by sitting next to Alice. +Frank would gain 91 happiness units by sitting next to Bob. +Frank would gain 8 happiness units by sitting next to Carol. +Frank would lose 66 happiness units by sitting next to David. +Frank would gain 97 happiness units by sitting next to Eric. +Frank would lose 9 happiness units by sitting next to George. +Frank would lose 92 happiness units by sitting next to Mallory. +George would lose 44 happiness units by sitting next to Alice. +George would lose 25 happiness units by sitting next to Bob. +George would gain 17 happiness units by sitting next to Carol. +George would gain 92 happiness units by sitting next to David. +George would lose 92 happiness units by sitting next to Eric. +George would gain 18 happiness units by sitting next to Frank. +George would gain 97 happiness units by sitting next to Mallory. +Mallory would gain 92 happiness units by sitting next to Alice. +Mallory would lose 96 happiness units by sitting next to Bob. +Mallory would lose 51 happiness units by sitting next to Carol. +Mallory would lose 81 happiness units by sitting next to David. +Mallory would gain 31 happiness units by sitting next to Eric. +Mallory would lose 73 happiness units by sitting next to Frank. +Mallory would lose 89 happiness units by sitting next to George. diff --git a/2015/day13/inputwithme b/2015/day13/inputwithme new file mode 100644 index 0000000..561614c --- /dev/null +++ b/2015/day13/inputwithme @@ -0,0 +1,71 @@ +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. +Alice would gain 0 happiness units by sitting next to Brian. +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. +Bob would gain 63 happiness units by sitting next to Eric. +Bob would gain 41 happiness units by sitting next to Frank. +Bob would gain 30 happiness units by sitting next to George. +Bob would gain 87 happiness units by sitting next to Mallory. +Bob would gain 0 happiness units by sitting next to Brian. +Carol would lose 35 happiness units by sitting next to Alice. +Carol would lose 99 happiness units by sitting next to Bob. +Carol would lose 51 happiness units by sitting next to David. +Carol would gain 95 happiness units by sitting next to Eric. +Carol would gain 90 happiness units by sitting next to Frank. +Carol would lose 16 happiness units by sitting next to George. +Carol would gain 94 happiness units by sitting next to Mallory. +Carol would gain 0 happiness units by sitting next to Brian. +David would gain 36 happiness units by sitting next to Alice. +David would lose 18 happiness units by sitting next to Bob. +David would lose 65 happiness units by sitting next to Carol. +David would lose 18 happiness units by sitting next to Eric. +David would lose 22 happiness units by sitting next to Frank. +David would gain 2 happiness units by sitting next to George. +David would gain 42 happiness units by sitting next to Mallory. +David would gain 0 happiness units by sitting next to Brian. +Eric would lose 65 happiness units by sitting next to Alice. +Eric would gain 24 happiness units by sitting next to Bob. +Eric would gain 100 happiness units by sitting next to Carol. +Eric would gain 51 happiness units by sitting next to David. +Eric would gain 21 happiness units by sitting next to Frank. +Eric would gain 55 happiness units by sitting next to George. +Eric would lose 44 happiness units by sitting next to Mallory. +Eric would gain 0 happiness units by sitting next to Brian. +Frank would lose 48 happiness units by sitting next to Alice. +Frank would gain 91 happiness units by sitting next to Bob. +Frank would gain 8 happiness units by sitting next to Carol. +Frank would lose 66 happiness units by sitting next to David. +Frank would gain 97 happiness units by sitting next to Eric. +Frank would lose 9 happiness units by sitting next to George. +Frank would lose 92 happiness units by sitting next to Mallory. +Frank would gain 0 happiness units by sitting next to Brian. +George would lose 44 happiness units by sitting next to Alice. +George would lose 25 happiness units by sitting next to Bob. +George would gain 17 happiness units by sitting next to Carol. +George would gain 92 happiness units by sitting next to David. +George would lose 92 happiness units by sitting next to Eric. +George would gain 18 happiness units by sitting next to Frank. +George would gain 97 happiness units by sitting next to Mallory. +George would gain 0 happiness units by sitting next to Brian. +Mallory would gain 92 happiness units by sitting next to Alice. +Mallory would lose 96 happiness units by sitting next to Bob. +Mallory would lose 51 happiness units by sitting next to Carol. +Mallory would lose 81 happiness units by sitting next to David. +Mallory would gain 31 happiness units by sitting next to Eric. +Mallory would lose 73 happiness units by sitting next to Frank. +Mallory would gain 0 happiness units by sitting next to Brian. +Mallory would lose 89 happiness units by sitting next to George. +Brian would gain 0 happiness units by sitting next to Alice. +Brian would gain 0 happiness units by sitting next to Bob. +Brian would gain 0 happiness units by sitting next to Carol. +Brian would gain 0 happiness units by sitting next to David. +Brian would gain 0 happiness units by sitting next to Eric. +Brian would gain 0 happiness units by sitting next to Frank. +Brian would gain 0 happiness units by sitting next to Mallory. diff --git a/2015/day13/main.go b/2015/day13/main.go new file mode 100644 index 0000000..fdf38aa --- /dev/null +++ b/2015/day13/main.go @@ -0,0 +1,157 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +var people map[string]person + +func main() { + var pplSlice []string + people = make(map[string]person) + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + for i := range input { + p := parseLine(input[i]) + people[p.name] = p + } + for i := range people { + pplSlice = append(pplSlice, people[i].name) + } + // Output all preferences + /* + for k, v := range people { + fmt.Println(k) + fmt.Println(" High: " + v.highName + " :: " + strconv.Itoa(v.highVal)) + for pk, pv := range v.prefs { + fmt.Println(" " + pk + ": " + strconv.Itoa(pv)) + } + } + */ + //getPerms(pplSlice) + first := pplSlice[0] + res := getPerms(pplSlice[1:]) + var high int + var arrangement []string + for i := range res { + tstArr := append([]string{first}, res[i]...) + tst := happinessFromStrings(tstArr) + if tst > high { + high = tst + arrangement = tstArr + } + } + fmt.Println("Highest: " + strconv.Itoa(high)) + fmt.Println(arrangement) +} + +func getPerms(ppl []string) [][]string { + var ret [][]string + if len(ppl) == 1 { + return append(ret, ppl) + } + + for j := range ppl { + var bld []string + for i := range ppl { + if i != j { + bld = append(bld, ppl[i]) + } + } + perms := getPerms(bld) + for i := range perms { + perms[i] = append([]string{ppl[j]}, perms[i]...) + ret = append(ret, perms[i]) + } + } + return ret +} + +func happinessFromStrings(pS []string) int { + var ppl []person + for i := range pS { + ppl = append(ppl, people[pS[i]]) + } + return happinessValue(ppl) +} + +func happinessValue(ppl []person) int { + var ret int + for i := range ppl { + p1, p2 := getNeighbors(ppl[i], ppl) + ret += ppl[i].prefs[p1.name] + ret += ppl[i].prefs[p2.name] + } + return ret +} + +func getNeighbors(p person, ppl []person) (person, person) { + var p1, p2 person + for idx := range ppl { + if ppl[idx].name == p.name { + if idx == 0 { + p1 = ppl[len(ppl)-1] + p2 = ppl[idx+1] + } else if idx == len(ppl)-1 { + p1 = ppl[idx-1] + p2 = ppl[0] + } else { + p1 = ppl[idx-1] + p2 = ppl[idx+1] + } + break + } + } + return p1, p2 +} + +type person struct { + name string + prefs map[string]int + highName string + highVal int + lowName string + lowVal int +} + +func parseLine(s string) person { + parts := strings.Split(s, " ") + who := parts[0] + direction := parts[2] + amount := mustAtoi(parts[3]) + nextTo := parts[10][:len(parts[10])-1] + if direction == "lose" { + amount = amount * -1 + } + var ret person + var ok bool + if ret, ok = people[who]; !ok { + ret = person{name: who} + ret.prefs = make(map[string]int) + } + ret.prefs[nextTo] = amount + if ret.highVal < amount || ret.highName == "" { + ret.highVal, ret.highName = amount, nextTo + } + if ret.lowVal > amount || ret.lowName == "" { + ret.lowVal, ret.lowName = amount, nextTo + } + return ret +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + } + return i +} diff --git a/2015/day13/problem b/2015/day13/problem new file mode 100644 index 0000000..d983dbb --- /dev/null +++ b/2015/day13/problem @@ -0,0 +1,96 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 13: Knights of the Dinner Table --- + + In years past, the holiday feast with your family hasn't gone so well. Not everyone gets along! + This year, you resolve, will be different. You're going to find the optimal seating arrangement + and avoid all those awkward conversations. + + You start by writing up a list of everyone invited and the amount their happiness would + increase or decrease if they were to find themselves sitting next to each other person. You + have a circular table that will be just big enough to fit everyone comfortably, and so each + person will have exactly two neighbors. + + For example, suppose you have only four attendees planned, and you calculate their potential + happiness as follows: + + Alice would gain 54 happiness units by sitting next to Bob. + Alice would lose 79 happiness units by sitting next to Carol. + Alice would lose 2 happiness units by sitting next to David. + Bob would gain 83 happiness units by sitting next to Alice. + Bob would lose 7 happiness units by sitting next to Carol. + Bob would lose 63 happiness units by sitting next to David. + Carol would lose 62 happiness units by sitting next to Alice. + Carol would gain 60 happiness units by sitting next to Bob. + Carol would gain 55 happiness units by sitting next to David. + David would gain 46 happiness units by sitting next to Alice. + David would lose 7 happiness units by sitting next to Bob. + David would gain 41 happiness units by sitting next to Carol. + + Then, if you seat Alice next to David, Alice would lose 2 happiness units (because David talks + so much), but David would gain 46 happiness units (because Alice is such a good listener), for + a total change of 44. + + If you continue around the table, you could then seat Bob next to Alice (Bob gains 83, Alice + gains 54). Finally, seat Carol, who sits next to Bob (Carol gains 60, Bob loses 7) and David + (Carol gains 55, David gains 41). The arrangement looks like this: + + +41 +46 + +55 David -2 + Carol Alice + +60 Bob +54 + -7 +83 + + After trying every other seating arrangement in this hypothetical scenario, you find that this + one is the most optimal, with a total change in happiness of 330. + + What is the total change in happiness for the optimal seating arrangement of the actual guest + list? + + Your puzzle answer was 733. + +--- Part Two --- + + In all the commotion, you realize that you forgot to seat yourself. At this point, you're + pretty apathetic toward the whole thing, and your happiness wouldn't really go up or down + regardless of who you sit next to. You assume everyone else would be just as ambivalent about + sitting next to you, too. + + So, add yourself to the list, and give all happiness relationships that involve you a score of + 0. + + What is the total change in happiness for the optimal seating arrangement that actually + includes yourself? + + Your puzzle answer was 725. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/13/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Knights+of+the+Dinner+Table%22+%2D+Day+13+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13&title=I%27ve+completed+%22Knights+of+the+Dinner+Table%22+%2D+Day+13+%2D+Advent+of+Code diff --git a/2015/day14/input b/2015/day14/input new file mode 100644 index 0000000..2af1170 --- /dev/null +++ b/2015/day14/input @@ -0,0 +1,9 @@ +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. +Blitzen can fly 19 km/s for 9 seconds, but then must rest for 158 seconds. +Comet can fly 13 km/s for 7 seconds, but then must rest for 82 seconds. +Cupid can fly 25 km/s for 6 seconds, but then must rest for 145 seconds. +Dasher can fly 14 km/s for 3 seconds, but then must rest for 38 seconds. +Dancer can fly 3 km/s for 16 seconds, but then must rest for 37 seconds. +Prancer can fly 25 km/s for 6 seconds, but then must rest for 143 seconds. diff --git a/2015/day14/main.go b/2015/day14/main.go new file mode 100644 index 0000000..2ac7c1e --- /dev/null +++ b/2015/day14/main.go @@ -0,0 +1,88 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +func main() { + if len(os.Args) < 2 { + fmt.Println("Usage: day14 ") + os.Exit(1) + } + raceTime := os.Args[1] + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + var allDeer []deer + for i := range input { + parts := strings.Split(input[i], " ") + allDeer = append(allDeer, *createDeer( + parts[0], + mustAtoi(parts[3]), + mustAtoi(parts[6]), + mustAtoi(parts[13]), + )) + } + fmt.Println("Race ends at " + raceTime) + endTime := mustAtoi(raceTime) + deerStars := make(map[string]int) + for i := 1; i <= endTime; i++ { + var topVal int + for j := range allDeer { + tmp := allDeer[j].travelFor(i) + if tmp > topVal { + topVal = tmp + } + } + for j := range allDeer { + if allDeer[j].travelFor(i) == topVal { + deerStars[allDeer[j].name]++ + } + } + } + for i := range deerStars { + fmt.Println(i + ": " + strconv.Itoa(deerStars[i])) + } +} + +type deer struct { + name string + speed int + moveDuration int + restDuration int +} + +func createDeer(n string, s, m, r int) *deer { + d := deer{n, s, m, r} + return &d +} + +func (d *deer) travelFor(s int) int { + var dist int + for s > 0 { + if s > d.moveDuration { + dist += d.speed * d.moveDuration + } else { + dist += d.speed * s + } + s -= d.moveDuration + s -= d.restDuration + } + return dist +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + } + return i +} diff --git a/2015/day14/problem b/2015/day14/problem new file mode 100644 index 0000000..9e85a62 --- /dev/null +++ b/2015/day14/problem @@ -0,0 +1,84 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 14: Reindeer Olympics --- + + This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally + to recover their energy. Santa would like to know which of his reindeer is fastest, and so he + has them race. + + Reindeer can only either be flying (always at their top speed) or resting (not moving at all), + and always spend whole seconds in either state. + + For example, suppose you have the following Reindeer: + + • Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. + • Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. + + After one second, Comet has gone 14 km, while Dancer has gone 16 km. After ten seconds, Comet + has gone 140 km, while Dancer has gone 160 km. On the eleventh second, Comet begins resting + (staying at 140 km), and Dancer continues on for a total distance of 176 km. On the 12th + second, both reindeer are resting. They continue to rest until the 138th second, when Comet + flies for another ten seconds. On the 174th second, Dancer flies for another 11 seconds. + + In this example, after the 1000th second, both reindeer are resting, and Comet is in the lead + at 1120 km (poor Dancer has only gotten 1056 km by that point). So, in this situation, Comet + would win (if the race ended at 1000 seconds). + + Given the descriptions of each reindeer (in your puzzle input), after exactly 2503 seconds, + what distance has the winning reindeer traveled? + + Your puzzle answer was 2660. + +--- Part Two --- + + Seeing how reindeer move in bursts, Santa decides he's not pleased with the old scoring system. + + Instead, at the end of each second, he awards one point to the reindeer currently in the lead. + (If there are multiple reindeer tied for the lead, they each get one point.) He keeps the + traditional 2503 second time limit, of course, as doing otherwise would be entirely ridiculous. + + Given the example reindeer from above, after the first second, Dancer is in the lead and gets + one point. He stays in the lead until several seconds into Comet's second burst: after the + 140th second, Comet pulls into the lead and gets his first point. Of course, since Dancer had + been in the lead for the 139 seconds before that, he has accumulated 139 points by the 140th + second. + + After the 1000th second, Dancer has accumulated 689 points, while poor Comet, our old champion, + only has 312. So, with the new scoring system, Dancer would win (if the race ended at 1000 + seconds). + + Again given the descriptions of each reindeer (in your puzzle input), after exactly 2503 + seconds, how many points does the winning reindeer have? + + Your puzzle answer was 1256. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/14/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Reindeer+Olympics%22+%2D+Day+14+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14&title=I%27ve+completed+%22Reindeer+Olympics%22+%2D+Day+14+%2D+Advent+of+Code diff --git a/2015/day14/sample_input b/2015/day14/sample_input new file mode 100644 index 0000000..706ceae --- /dev/null +++ b/2015/day14/sample_input @@ -0,0 +1,2 @@ +Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. +Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. diff --git a/2015/day15/input b/2015/day15/input new file mode 100644 index 0000000..634c6a5 --- /dev/null +++ b/2015/day15/input @@ -0,0 +1,4 @@ +Frosting: capacity 4, durability -2, flavor 0, texture 0, calories 5 +Candy: capacity 0, durability 5, flavor -1, texture 0, calories 8 +Butterscotch: capacity -1, durability 0, flavor 5, texture 0, calories 6 +Sugar: capacity 0, durability 0, flavor -2, texture 2, calories 1 diff --git a/2015/day15/main.go b/2015/day15/main.go new file mode 100644 index 0000000..5c15dc3 --- /dev/null +++ b/2015/day15/main.go @@ -0,0 +1,156 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +var ings []ingredient + +func main() { + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + var stringIngs []string + total := 100 + for i := range input { + bldI := *createIngredient(input[i]) + ings = append(ings, bldI) + stringIngs = append(stringIngs, bldI.name) + } + + combis := getIntCombis(total, len(stringIngs)) + ingPerms := getStringPermus(stringIngs) + + var highVal int + var highMap map[string]int + for h := range combis { + for i := range ingPerms { + tstMap := make(map[string]int) + for j := range ingPerms[i] { + tstMap[ingPerms[i][j]] = combis[h][j] + } + tmp, cals := calcValue(tstMap) + if cals == 500 && tmp > highVal { + highVal = tmp + highMap = tstMap + + fmt.Print(strconv.Itoa(tmp)) + fmt.Print(" :: ") + fmt.Println(tstMap) + } + } + } + fmt.Println() + fmt.Println(highMap) + fmt.Println("Highest Value: " + strconv.Itoa(highVal)) +} + +func getStringPermus(vals []string) [][]string { + var ret [][]string + if len(vals) == 1 { + return append(ret, vals) + } + + for j := range vals { + var bld []string + for i := range vals { + if i != j { + bld = append(bld, vals[i]) + } + } + tmp := getStringPermus(bld) + for i := range tmp { + tmp[i] = append([]string{vals[j]}, tmp[i]...) + ret = append(ret, tmp[i]) + } + } + return ret +} + +func getIntCombis(total, containers int) [][]int { + var ret [][]int + if containers == 2 { + for i := total; i >= 0; i-- { //(total / 2); i-- { + ret = append(ret, []int{i, (total - i)}) + } + return ret + } + for i := total; i >= 0; i-- { //(total / 2); i-- { + tmp := getIntCombis((total - i), (containers - 1)) + for j := 0; j < len(tmp); j++ { + tmp[j] = append([]int{i}, tmp[j]...) + ret = append(ret, tmp[j]) + } + } + return ret +} + +func getIngredient(name string) *ingredient { + for i := range ings { + if ings[i].name == name { + return &ings[i] + } + } + return nil +} + +func calcValue(list map[string]int) (int, int) { + tmp := new(ingredient) + for kname, v := range list { + k := getIngredient(kname) + tmp.capacity += k.capacity * v + tmp.durability += k.durability * v + tmp.flavor += k.flavor * v + tmp.texture += k.texture * v + tmp.calories += k.calories * v + } + if tmp.texture < 0 || tmp.durability < 0 || tmp.flavor < 0 || tmp.texture < 0 { + return 0, 0 + } + return (tmp.capacity * tmp.durability * tmp.flavor * tmp.texture), tmp.calories +} + +type ingredient struct { + name string + capacity int + durability int + flavor int + texture int + calories int +} + +func createIngredient(s string) *ingredient { + parts := strings.Split(s, " ") + name := parts[0] + name = name[:len(name)-1] + c := parts[2] + d := parts[4] + f := parts[6] + t := parts[8] + cal := parts[10] + i := ingredient{ + name: name, + capacity: mustAtoi(c[:len(c)-1]), + durability: mustAtoi(d[:len(d)-1]), + flavor: mustAtoi(f[:len(f)-1]), + texture: mustAtoi(t[:len(t)-1]), + calories: mustAtoi(cal), + } + return &i +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + } + return i +} diff --git a/2015/day15/problem b/2015/day15/problem new file mode 100644 index 0000000..52b98df --- /dev/null +++ b/2015/day15/problem @@ -0,0 +1,92 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 15: Science for Hungry People --- + + Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to + do is find the right balance of ingredients. + + Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a list of the + remaining ingredients you could use to finish the recipe (your puzzle input) and their + properties per teaspoon: + + • capacity (how well it helps the cookie absorb milk) + • durability (how well it keeps the cookie intact when full of milk) + • flavor (how tasty it makes the cookie) + • texture (how it improves the feel of the cookie) + • calories (how many calories it adds to the cookie) + + You can only measure ingredients in whole-teaspoon amounts accurately, and you have to be + accurate so you can reproduce your results in the future. The total score of a cookie can be + found by adding up each of the properties (negative totals become 0) and then multiplying + together everything except calories. + + For instance, suppose you have these two ingredients: + + Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8 + Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3 + + Then, choosing to use 44 teaspoons of butterscotch and 56 teaspoons of cinnamon (because the + amounts of each ingredient must add up to 100) would result in a cookie with the following + properties: + + • A capacity of 44*-1 + 56*2 = 68 + • A durability of 44*-2 + 56*3 = 80 + • A flavor of 44*6 + 56*-2 = 152 + • A texture of 44*3 + 56*-1 = 76 + + Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now) results in a total + score of 62842880, which happens to be the best score possible given these ingredients. If any + properties had produced a negative total, it would have instead become zero, causing the whole + score to multiply to zero. + + Given the ingredients in your kitchen and their properties, what is the total score of the + highest-scoring cookie you can make? + + Your puzzle answer was 18965440. + +--- Part Two --- + + Your cookie recipe becomes wildly popular! Someone asks if you can make another recipe that has + exactly 500 calories per cookie (so they can use it as a meal replacement). Keep the rest of + your award-winning process the same (100 teaspoons, same ingredients, same scoring system). + + For example, given the ingredients above, if you had instead selected 40 teaspoons of + butterscotch and 60 teaspoons of cinnamon (which still adds to 100), the total calorie count + would be 40*8 + 60*3 = 500. The total score would go down, though: only 57600000, the best you + can do in such trying circumstances. + + Given the ingredients in your kitchen and their properties, what is the total score of the + highest-scoring cookie you can make with a calorie total of 500? + + Your puzzle answer was 15862900. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/15/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&title=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code diff --git a/2015/day15/sample_input b/2015/day15/sample_input new file mode 100644 index 0000000..39e7975 --- /dev/null +++ b/2015/day15/sample_input @@ -0,0 +1,2 @@ +B: c -1, dur -2, flav 6, tex 3, cal 8 +C: c 2, dur 3, flav -2, tex -1, cal 3 \ No newline at end of file diff --git a/2015/day16/input b/2015/day16/input new file mode 100644 index 0000000..ddaeefc --- /dev/null +++ b/2015/day16/input @@ -0,0 +1,500 @@ +Sue 1: cars: 9, akitas: 3, goldfish: 0 +Sue 2: akitas: 9, children: 3, samoyeds: 9 +Sue 3: trees: 6, cars: 6, children: 4 +Sue 4: trees: 4, vizslas: 4, goldfish: 9 +Sue 5: akitas: 9, vizslas: 7, cars: 5 +Sue 6: vizslas: 6, goldfish: 6, akitas: 3 +Sue 7: pomeranians: 5, samoyeds: 0, perfumes: 10 +Sue 8: cars: 10, pomeranians: 7, goldfish: 8 +Sue 9: trees: 2, vizslas: 7, samoyeds: 6 +Sue 10: perfumes: 5, pomeranians: 4, children: 9 +Sue 11: vizslas: 5, perfumes: 8, cars: 10 +Sue 12: children: 10, cars: 6, perfumes: 5 +Sue 13: cats: 4, samoyeds: 7, pomeranians: 8 +Sue 14: perfumes: 6, goldfish: 10, children: 7 +Sue 15: perfumes: 4, pomeranians: 3, cars: 6 +Sue 16: perfumes: 7, cars: 9, pomeranians: 6 +Sue 17: goldfish: 3, cars: 6, vizslas: 7 +Sue 18: perfumes: 6, cars: 7, goldfish: 3 +Sue 19: trees: 0, akitas: 3, pomeranians: 8 +Sue 20: goldfish: 6, trees: 2, akitas: 6 +Sue 21: pomeranians: 9, akitas: 9, samoyeds: 9 +Sue 22: vizslas: 2, cars: 9, perfumes: 5 +Sue 23: goldfish: 10, samoyeds: 8, children: 9 +Sue 24: akitas: 4, goldfish: 1, vizslas: 5 +Sue 25: goldfish: 10, trees: 8, perfumes: 6 +Sue 26: vizslas: 5, akitas: 8, trees: 1 +Sue 27: trees: 3, cars: 6, perfumes: 2 +Sue 28: goldfish: 8, trees: 7, akitas: 10 +Sue 29: children: 5, trees: 1, goldfish: 10 +Sue 30: vizslas: 3, perfumes: 8, akitas: 3 +Sue 31: cars: 6, children: 10, perfumes: 7 +Sue 32: cars: 10, perfumes: 3, goldfish: 10 +Sue 33: perfumes: 9, vizslas: 3, akitas: 4 +Sue 34: perfumes: 10, vizslas: 7, children: 8 +Sue 35: cars: 5, perfumes: 5, vizslas: 9 +Sue 36: trees: 9, cars: 9, akitas: 7 +Sue 37: samoyeds: 9, perfumes: 2, cars: 10 +Sue 38: akitas: 7, cars: 5, trees: 5 +Sue 39: goldfish: 8, trees: 9, cars: 10 +Sue 40: trees: 0, cats: 1, pomeranians: 1 +Sue 41: pomeranians: 6, perfumes: 9, samoyeds: 1 +Sue 42: vizslas: 6, akitas: 3, pomeranians: 1 +Sue 43: vizslas: 2, perfumes: 3, pomeranians: 6 +Sue 44: akitas: 5, pomeranians: 0, vizslas: 10 +Sue 45: vizslas: 4, goldfish: 1, cars: 5 +Sue 46: cars: 4, vizslas: 8, cats: 0 +Sue 47: cats: 5, children: 8, pomeranians: 2 +Sue 48: vizslas: 3, perfumes: 6, cats: 0 +Sue 49: akitas: 7, perfumes: 0, trees: 7 +Sue 50: trees: 4, akitas: 10, vizslas: 2 +Sue 51: goldfish: 10, cars: 9, trees: 4 +Sue 52: cars: 5, children: 9, perfumes: 0 +Sue 53: vizslas: 5, cars: 3, cats: 8 +Sue 54: cars: 5, akitas: 1, goldfish: 10 +Sue 55: akitas: 10, vizslas: 2, cars: 6 +Sue 56: cats: 6, trees: 0, cars: 4 +Sue 57: vizslas: 1, akitas: 1, samoyeds: 7 +Sue 58: samoyeds: 6, vizslas: 1, akitas: 7 +Sue 59: akitas: 9, cars: 8, vizslas: 1 +Sue 60: cars: 6, vizslas: 7, goldfish: 0 +Sue 61: pomeranians: 5, akitas: 6, vizslas: 2 +Sue 62: samoyeds: 2, cats: 8, goldfish: 7 +Sue 63: vizslas: 10, goldfish: 7, samoyeds: 9 +Sue 64: perfumes: 2, trees: 1, akitas: 6 +Sue 65: cars: 8, perfumes: 10, vizslas: 9 +Sue 66: akitas: 8, vizslas: 8, perfumes: 8 +Sue 67: goldfish: 7, cars: 9, samoyeds: 9 +Sue 68: perfumes: 2, children: 7, akitas: 1 +Sue 69: perfumes: 7, vizslas: 9, akitas: 1 +Sue 70: samoyeds: 3, vizslas: 1, trees: 1 +Sue 71: vizslas: 8, goldfish: 7, trees: 9 +Sue 72: goldfish: 8, cars: 6, trees: 9 +Sue 73: perfumes: 5, cars: 10, samoyeds: 7 +Sue 74: pomeranians: 4, perfumes: 3, cars: 5 +Sue 75: samoyeds: 1, perfumes: 1, pomeranians: 1 +Sue 76: goldfish: 4, cats: 6, akitas: 7 +Sue 77: perfumes: 5, akitas: 4, vizslas: 8 +Sue 78: perfumes: 4, cats: 3, children: 4 +Sue 79: vizslas: 5, pomeranians: 9, samoyeds: 7 +Sue 80: cars: 3, samoyeds: 5, pomeranians: 7 +Sue 81: vizslas: 2, samoyeds: 4, perfumes: 2 +Sue 82: trees: 1, akitas: 10, vizslas: 9 +Sue 83: vizslas: 0, akitas: 2, samoyeds: 5 +Sue 84: perfumes: 5, vizslas: 7, children: 8 +Sue 85: cats: 3, children: 2, trees: 0 +Sue 86: cars: 3, perfumes: 2, goldfish: 2 +Sue 87: trees: 1, akitas: 7, vizslas: 0 +Sue 88: trees: 1, akitas: 2, samoyeds: 1 +Sue 89: cars: 4, vizslas: 8, akitas: 1 +Sue 90: perfumes: 5, cats: 3, vizslas: 0 +Sue 91: samoyeds: 7, cats: 6, goldfish: 8 +Sue 92: samoyeds: 10, cats: 0, cars: 7 +Sue 93: cars: 6, akitas: 7, samoyeds: 2 +Sue 94: perfumes: 0, goldfish: 6, trees: 9 +Sue 95: cars: 6, pomeranians: 2, samoyeds: 8 +Sue 96: cars: 2, trees: 9, samoyeds: 4 +Sue 97: goldfish: 5, trees: 1, children: 0 +Sue 98: akitas: 9, goldfish: 7, children: 6 +Sue 99: goldfish: 9, akitas: 0, pomeranians: 0 +Sue 100: samoyeds: 6, children: 8, vizslas: 5 +Sue 101: vizslas: 6, cars: 5, goldfish: 4 +Sue 102: vizslas: 6, akitas: 2, perfumes: 6 +Sue 103: samoyeds: 3, akitas: 7, children: 4 +Sue 104: cars: 3, perfumes: 10, cats: 6 +Sue 105: vizslas: 9, pomeranians: 0, cars: 1 +Sue 106: cats: 6, samoyeds: 8, pomeranians: 5 +Sue 107: cars: 7, trees: 4, akitas: 10 +Sue 108: perfumes: 3, vizslas: 1, goldfish: 9 +Sue 109: trees: 6, cars: 8, goldfish: 5 +Sue 110: pomeranians: 2, children: 1, vizslas: 7 +Sue 111: akitas: 0, vizslas: 8, cars: 0 +Sue 112: goldfish: 3, vizslas: 6, akitas: 2 +Sue 113: akitas: 10, pomeranians: 7, perfumes: 7 +Sue 114: cars: 10, cats: 2, vizslas: 8 +Sue 115: akitas: 8, trees: 1, vizslas: 2 +Sue 116: vizslas: 2, akitas: 7, perfumes: 1 +Sue 117: goldfish: 0, vizslas: 10, trees: 9 +Sue 118: trees: 3, cars: 0, goldfish: 0 +Sue 119: perfumes: 7, goldfish: 5, trees: 9 +Sue 120: children: 9, vizslas: 3, trees: 5 +Sue 121: vizslas: 1, goldfish: 7, akitas: 10 +Sue 122: perfumes: 1, cars: 6, trees: 1 +Sue 123: akitas: 2, vizslas: 0, goldfish: 7 +Sue 124: vizslas: 10, pomeranians: 7, akitas: 0 +Sue 125: perfumes: 4, cats: 5, vizslas: 2 +Sue 126: cars: 6, samoyeds: 8, akitas: 3 +Sue 127: trees: 9, goldfish: 7, akitas: 9 +Sue 128: cars: 8, trees: 0, perfumes: 2 +Sue 129: pomeranians: 7, vizslas: 2, perfumes: 6 +Sue 130: vizslas: 9, pomeranians: 3, trees: 6 +Sue 131: vizslas: 7, cars: 9, perfumes: 1 +Sue 132: akitas: 2, pomeranians: 9, vizslas: 7 +Sue 133: trees: 9, pomeranians: 10, samoyeds: 0 +Sue 134: children: 4, akitas: 10, perfumes: 4 +Sue 135: vizslas: 1, cats: 1, trees: 8 +Sue 136: samoyeds: 7, cars: 8, goldfish: 5 +Sue 137: perfumes: 0, children: 1, pomeranians: 10 +Sue 138: vizslas: 4, perfumes: 5, cars: 5 +Sue 139: trees: 2, perfumes: 8, goldfish: 0 +Sue 140: cars: 10, akitas: 5, goldfish: 7 +Sue 141: children: 4, trees: 3, goldfish: 8 +Sue 142: cars: 8, perfumes: 6, trees: 7 +Sue 143: akitas: 6, goldfish: 0, trees: 10 +Sue 144: akitas: 7, pomeranians: 10, perfumes: 10 +Sue 145: trees: 10, vizslas: 3, goldfish: 4 +Sue 146: samoyeds: 4, akitas: 3, perfumes: 6 +Sue 147: akitas: 8, perfumes: 2, pomeranians: 10 +Sue 148: cars: 2, perfumes: 0, goldfish: 8 +Sue 149: goldfish: 6, akitas: 7, perfumes: 6 +Sue 150: cars: 2, pomeranians: 5, perfumes: 4 +Sue 151: goldfish: 1, cars: 5, trees: 0 +Sue 152: pomeranians: 4, cars: 7, children: 1 +Sue 153: goldfish: 8, cars: 1, children: 10 +Sue 154: cars: 6, perfumes: 8, trees: 1 +Sue 155: akitas: 4, perfumes: 6, pomeranians: 2 +Sue 156: pomeranians: 5, cars: 4, akitas: 1 +Sue 157: cats: 5, cars: 9, goldfish: 8 +Sue 158: vizslas: 5, samoyeds: 1, children: 7 +Sue 159: vizslas: 1, perfumes: 3, akitas: 1 +Sue 160: goldfish: 10, pomeranians: 9, perfumes: 5 +Sue 161: samoyeds: 3, trees: 7, cars: 2 +Sue 162: cars: 2, pomeranians: 1, vizslas: 6 +Sue 163: vizslas: 3, perfumes: 5, akitas: 6 +Sue 164: vizslas: 1, trees: 0, akitas: 5 +Sue 165: vizslas: 5, cars: 6, pomeranians: 8 +Sue 166: cars: 10, perfumes: 2, trees: 9 +Sue 167: cars: 10, pomeranians: 6, perfumes: 4 +Sue 168: akitas: 7, trees: 10, goldfish: 7 +Sue 169: akitas: 1, perfumes: 10, cars: 10 +Sue 170: akitas: 5, samoyeds: 8, vizslas: 6 +Sue 171: children: 3, akitas: 2, vizslas: 3 +Sue 172: goldfish: 5, vizslas: 5, perfumes: 9 +Sue 173: perfumes: 5, goldfish: 10, trees: 5 +Sue 174: akitas: 5, vizslas: 2, children: 7 +Sue 175: perfumes: 5, cars: 7, samoyeds: 2 +Sue 176: cars: 8, vizslas: 10, akitas: 7 +Sue 177: perfumes: 7, children: 8, goldfish: 7 +Sue 178: cars: 1, pomeranians: 9, samoyeds: 0 +Sue 179: perfumes: 6, cars: 2, trees: 6 +Sue 180: trees: 3, vizslas: 7, children: 3 +Sue 181: vizslas: 8, samoyeds: 2, trees: 9 +Sue 182: perfumes: 3, cats: 1, children: 5 +Sue 183: akitas: 9, cats: 6, children: 3 +Sue 184: pomeranians: 9, cars: 6, perfumes: 8 +Sue 185: vizslas: 9, trees: 0, akitas: 9 +Sue 186: perfumes: 6, cars: 5, goldfish: 5 +Sue 187: perfumes: 4, cats: 7, vizslas: 2 +Sue 188: akitas: 7, cars: 4, children: 10 +Sue 189: akitas: 0, goldfish: 7, vizslas: 5 +Sue 190: akitas: 5, cars: 5, cats: 6 +Sue 191: cars: 6, children: 0, perfumes: 3 +Sue 192: cats: 2, perfumes: 10, goldfish: 7 +Sue 193: trees: 1, perfumes: 0, cars: 8 +Sue 194: perfumes: 9, children: 4, cats: 6 +Sue 195: akitas: 7, trees: 3, goldfish: 6 +Sue 196: goldfish: 8, cars: 8, samoyeds: 0 +Sue 197: cats: 0, akitas: 10, vizslas: 0 +Sue 198: goldfish: 1, perfumes: 3, cars: 8 +Sue 199: akitas: 10, vizslas: 5, samoyeds: 6 +Sue 200: pomeranians: 9, goldfish: 9, samoyeds: 7 +Sue 201: samoyeds: 0, goldfish: 7, akitas: 6 +Sue 202: vizslas: 0, goldfish: 2, akitas: 1 +Sue 203: goldfish: 3, children: 0, vizslas: 8 +Sue 204: cars: 8, trees: 2, perfumes: 2 +Sue 205: cars: 4, perfumes: 5, goldfish: 8 +Sue 206: vizslas: 3, trees: 2, akitas: 1 +Sue 207: cars: 7, goldfish: 5, trees: 1 +Sue 208: goldfish: 1, cars: 6, vizslas: 8 +Sue 209: cats: 4, trees: 1, children: 0 +Sue 210: cats: 10, children: 0, perfumes: 0 +Sue 211: cars: 4, pomeranians: 7, samoyeds: 5 +Sue 212: cars: 2, pomeranians: 10, trees: 1 +Sue 213: trees: 10, cats: 5, cars: 10 +Sue 214: perfumes: 5, trees: 1, vizslas: 1 +Sue 215: akitas: 10, vizslas: 8, samoyeds: 8 +Sue 216: vizslas: 2, cats: 5, pomeranians: 3 +Sue 217: akitas: 10, perfumes: 0, cats: 10 +Sue 218: trees: 8, cats: 5, vizslas: 2 +Sue 219: goldfish: 10, perfumes: 8, children: 2 +Sue 220: samoyeds: 9, trees: 8, vizslas: 7 +Sue 221: children: 7, trees: 6, cars: 6 +Sue 222: cats: 4, akitas: 5, pomeranians: 0 +Sue 223: trees: 8, goldfish: 2, perfumes: 8 +Sue 224: pomeranians: 9, cars: 8, akitas: 5 +Sue 225: akitas: 10, vizslas: 0, trees: 2 +Sue 226: akitas: 8, cats: 6, cars: 7 +Sue 227: trees: 1, akitas: 3, goldfish: 4 +Sue 228: pomeranians: 6, cats: 3, goldfish: 3 +Sue 229: trees: 10, perfumes: 3, vizslas: 7 +Sue 230: perfumes: 8, cars: 7, akitas: 0 +Sue 231: perfumes: 10, goldfish: 4, cars: 6 +Sue 232: goldfish: 7, trees: 3, cats: 2 +Sue 233: perfumes: 6, trees: 4, akitas: 4 +Sue 234: goldfish: 9, cats: 4, cars: 7 +Sue 235: pomeranians: 6, vizslas: 0, akitas: 6 +Sue 236: samoyeds: 5, cars: 5, children: 4 +Sue 237: vizslas: 10, cars: 4, goldfish: 4 +Sue 238: goldfish: 3, samoyeds: 7, akitas: 2 +Sue 239: cats: 8, children: 2, vizslas: 7 +Sue 240: cars: 9, perfumes: 4, trees: 9 +Sue 241: trees: 8, vizslas: 2, goldfish: 5 +Sue 242: cars: 6, trees: 3, vizslas: 3 +Sue 243: cats: 6, children: 7, cars: 4 +Sue 244: cats: 10, perfumes: 2, goldfish: 7 +Sue 245: akitas: 8, cats: 10, perfumes: 8 +Sue 246: vizslas: 8, akitas: 5, perfumes: 10 +Sue 247: goldfish: 2, vizslas: 5, akitas: 7 +Sue 248: akitas: 3, perfumes: 0, trees: 10 +Sue 249: cats: 4, vizslas: 5, pomeranians: 6 +Sue 250: children: 3, vizslas: 7, perfumes: 2 +Sue 251: cars: 0, pomeranians: 10, perfumes: 0 +Sue 252: akitas: 0, goldfish: 9, cars: 6 +Sue 253: perfumes: 7, cars: 4, samoyeds: 5 +Sue 254: akitas: 9, trees: 10, cars: 4 +Sue 255: samoyeds: 10, children: 6, akitas: 7 +Sue 256: trees: 8, goldfish: 8, perfumes: 8 +Sue 257: goldfish: 3, akitas: 2, perfumes: 6 +Sue 258: cats: 7, trees: 0, vizslas: 1 +Sue 259: perfumes: 7, cars: 7, akitas: 7 +Sue 260: goldfish: 0, vizslas: 0, samoyeds: 2 +Sue 261: vizslas: 2, children: 2, cats: 3 +Sue 262: vizslas: 2, pomeranians: 9, samoyeds: 3 +Sue 263: cats: 1, akitas: 3, vizslas: 1 +Sue 264: pomeranians: 10, trees: 2, goldfish: 7 +Sue 265: samoyeds: 5, trees: 7, perfumes: 4 +Sue 266: perfumes: 10, cars: 1, pomeranians: 3 +Sue 267: trees: 6, goldfish: 1, cars: 0 +Sue 268: cars: 6, samoyeds: 4, pomeranians: 5 +Sue 269: goldfish: 3, vizslas: 3, akitas: 3 +Sue 270: children: 5, cats: 0, cars: 4 +Sue 271: goldfish: 3, perfumes: 8, pomeranians: 7 +Sue 272: samoyeds: 6, cars: 7, perfumes: 10 +Sue 273: trees: 4, cars: 2, vizslas: 7 +Sue 274: samoyeds: 10, perfumes: 9, goldfish: 6 +Sue 275: cars: 4, trees: 2, perfumes: 7 +Sue 276: akitas: 3, perfumes: 9, cars: 9 +Sue 277: akitas: 8, vizslas: 2, cats: 6 +Sue 278: trees: 5, goldfish: 7, akitas: 3 +Sue 279: perfumes: 9, cars: 8, vizslas: 2 +Sue 280: trees: 3, vizslas: 0, children: 0 +Sue 281: cars: 7, trees: 2, cats: 5 +Sue 282: vizslas: 4, cars: 10, cats: 3 +Sue 283: akitas: 10, cats: 3, samoyeds: 9 +Sue 284: trees: 7, children: 5, goldfish: 6 +Sue 285: cars: 2, perfumes: 5, cats: 7 +Sue 286: samoyeds: 5, trees: 10, goldfish: 6 +Sue 287: goldfish: 10, perfumes: 4, trees: 7 +Sue 288: vizslas: 9, trees: 9, perfumes: 0 +Sue 289: trees: 4, goldfish: 9, vizslas: 8 +Sue 290: vizslas: 3, cars: 3, trees: 2 +Sue 291: goldfish: 2, akitas: 2, trees: 2 +Sue 292: children: 1, cars: 0, vizslas: 5 +Sue 293: trees: 5, akitas: 4, goldfish: 6 +Sue 294: akitas: 3, vizslas: 7, pomeranians: 5 +Sue 295: goldfish: 10, vizslas: 3, trees: 1 +Sue 296: cars: 2, trees: 1, akitas: 0 +Sue 297: akitas: 10, vizslas: 6, samoyeds: 2 +Sue 298: children: 5, trees: 1, samoyeds: 9 +Sue 299: perfumes: 9, trees: 6, vizslas: 1 +Sue 300: akitas: 7, pomeranians: 6, vizslas: 6 +Sue 301: cats: 7, children: 6, vizslas: 7 +Sue 302: trees: 2, vizslas: 7, samoyeds: 4 +Sue 303: goldfish: 0, samoyeds: 10, cars: 4 +Sue 304: pomeranians: 9, children: 3, vizslas: 5 +Sue 305: akitas: 8, vizslas: 4, cars: 5 +Sue 306: akitas: 0, perfumes: 2, pomeranians: 10 +Sue 307: akitas: 9, cars: 0, trees: 2 +Sue 308: vizslas: 10, goldfish: 8, akitas: 6 +Sue 309: trees: 0, cats: 6, perfumes: 2 +Sue 310: vizslas: 10, cars: 1, trees: 4 +Sue 311: goldfish: 8, perfumes: 6, cats: 3 +Sue 312: goldfish: 0, children: 1, akitas: 2 +Sue 313: pomeranians: 10, trees: 6, samoyeds: 6 +Sue 314: vizslas: 5, akitas: 4, pomeranians: 2 +Sue 315: goldfish: 7, trees: 0, akitas: 5 +Sue 316: goldfish: 4, vizslas: 5, cars: 7 +Sue 317: perfumes: 7, cats: 10, cars: 4 +Sue 318: samoyeds: 10, cars: 9, trees: 7 +Sue 319: pomeranians: 8, vizslas: 6, cars: 3 +Sue 320: cars: 4, cats: 9, akitas: 4 +Sue 321: cars: 6, trees: 2, perfumes: 6 +Sue 322: goldfish: 1, cats: 2, perfumes: 4 +Sue 323: akitas: 6, cats: 5, cars: 8 +Sue 324: cats: 4, vizslas: 9, akitas: 0 +Sue 325: children: 8, samoyeds: 9, trees: 4 +Sue 326: vizslas: 2, samoyeds: 10, perfumes: 7 +Sue 327: goldfish: 7, pomeranians: 4, akitas: 10 +Sue 328: perfumes: 8, cats: 4, akitas: 10 +Sue 329: trees: 0, cars: 9, goldfish: 3 +Sue 330: trees: 5, samoyeds: 7, perfumes: 8 +Sue 331: cars: 4, perfumes: 2, goldfish: 0 +Sue 332: vizslas: 4, pomeranians: 7, akitas: 1 +Sue 333: akitas: 4, goldfish: 3, perfumes: 0 +Sue 334: samoyeds: 3, akitas: 10, vizslas: 0 +Sue 335: goldfish: 1, akitas: 7, vizslas: 6 +Sue 336: perfumes: 1, goldfish: 1, pomeranians: 8 +Sue 337: children: 5, cars: 4, cats: 4 +Sue 338: vizslas: 5, cars: 10, cats: 3 +Sue 339: trees: 2, goldfish: 3, cars: 1 +Sue 340: trees: 10, goldfish: 6, perfumes: 2 +Sue 341: akitas: 5, trees: 6, cats: 3 +Sue 342: cars: 10, children: 8, goldfish: 0 +Sue 343: cats: 2, akitas: 0, pomeranians: 4 +Sue 344: perfumes: 1, vizslas: 3, cars: 3 +Sue 345: samoyeds: 8, cats: 5, perfumes: 8 +Sue 346: cars: 5, akitas: 10, trees: 2 +Sue 347: vizslas: 9, akitas: 9, cars: 3 +Sue 348: cars: 3, perfumes: 1, pomeranians: 9 +Sue 349: akitas: 1, cars: 4, perfumes: 0 +Sue 350: perfumes: 8, vizslas: 2, trees: 6 +Sue 351: pomeranians: 5, akitas: 9, cats: 8 +Sue 352: pomeranians: 8, vizslas: 3, goldfish: 10 +Sue 353: trees: 2, pomeranians: 0, goldfish: 6 +Sue 354: cats: 5, akitas: 7, goldfish: 6 +Sue 355: goldfish: 6, children: 4, trees: 10 +Sue 356: children: 1, trees: 3, akitas: 7 +Sue 357: trees: 2, samoyeds: 10, goldfish: 3 +Sue 358: samoyeds: 10, cats: 0, goldfish: 0 +Sue 359: perfumes: 3, children: 6, pomeranians: 1 +Sue 360: cars: 10, pomeranians: 1, samoyeds: 5 +Sue 361: samoyeds: 9, pomeranians: 7, perfumes: 6 +Sue 362: goldfish: 6, trees: 8, perfumes: 9 +Sue 363: samoyeds: 10, pomeranians: 9, children: 10 +Sue 364: perfumes: 3, goldfish: 7, cars: 9 +Sue 365: cats: 3, children: 4, samoyeds: 8 +Sue 366: trees: 0, cars: 10, vizslas: 10 +Sue 367: pomeranians: 10, children: 8, perfumes: 2 +Sue 368: cars: 5, vizslas: 0, samoyeds: 3 +Sue 369: trees: 1, goldfish: 8, cars: 8 +Sue 370: vizslas: 0, cars: 2, perfumes: 5 +Sue 371: trees: 2, cars: 3, vizslas: 8 +Sue 372: trees: 10, children: 9, cats: 1 +Sue 373: pomeranians: 3, perfumes: 1, vizslas: 0 +Sue 374: vizslas: 0, perfumes: 6, trees: 0 +Sue 375: vizslas: 7, pomeranians: 1, akitas: 10 +Sue 376: vizslas: 8, trees: 2, cars: 10 +Sue 377: perfumes: 9, cats: 5, goldfish: 5 +Sue 378: cats: 0, akitas: 10, perfumes: 9 +Sue 379: cars: 4, akitas: 1, trees: 1 +Sue 380: cars: 4, perfumes: 5, trees: 3 +Sue 381: goldfish: 3, akitas: 5, samoyeds: 9 +Sue 382: goldfish: 7, perfumes: 5, trees: 5 +Sue 383: akitas: 4, cats: 6, cars: 8 +Sue 384: children: 6, goldfish: 10, akitas: 7 +Sue 385: akitas: 7, vizslas: 5, perfumes: 10 +Sue 386: children: 7, vizslas: 10, akitas: 10 +Sue 387: goldfish: 6, akitas: 7, trees: 2 +Sue 388: vizslas: 6, trees: 1, akitas: 2 +Sue 389: cars: 5, vizslas: 3, akitas: 7 +Sue 390: vizslas: 4, cats: 8, perfumes: 7 +Sue 391: akitas: 3, trees: 0, children: 2 +Sue 392: cats: 7, cars: 3, children: 9 +Sue 393: trees: 10, vizslas: 3, goldfish: 7 +Sue 394: perfumes: 0, goldfish: 7, akitas: 4 +Sue 395: cats: 6, cars: 7, vizslas: 0 +Sue 396: vizslas: 4, perfumes: 6, goldfish: 5 +Sue 397: pomeranians: 8, trees: 1, akitas: 9 +Sue 398: goldfish: 7, pomeranians: 6, samoyeds: 9 +Sue 399: perfumes: 10, cars: 1, trees: 8 +Sue 400: trees: 0, goldfish: 9, children: 6 +Sue 401: trees: 1, cars: 6, pomeranians: 8 +Sue 402: perfumes: 9, cars: 0, vizslas: 10 +Sue 403: samoyeds: 4, akitas: 1, vizslas: 9 +Sue 404: perfumes: 0, trees: 2, cars: 4 +Sue 405: akitas: 0, perfumes: 5, samoyeds: 4 +Sue 406: akitas: 8, vizslas: 6, children: 2 +Sue 407: children: 1, trees: 8, goldfish: 10 +Sue 408: pomeranians: 4, trees: 10, cars: 9 +Sue 409: perfumes: 5, vizslas: 5, akitas: 4 +Sue 410: trees: 1, akitas: 10, vizslas: 6 +Sue 411: samoyeds: 0, goldfish: 9, perfumes: 7 +Sue 412: goldfish: 7, samoyeds: 10, trees: 1 +Sue 413: samoyeds: 0, pomeranians: 10, vizslas: 6 +Sue 414: children: 2, cars: 10, samoyeds: 2 +Sue 415: trees: 2, goldfish: 8, cars: 0 +Sue 416: samoyeds: 4, goldfish: 9, trees: 2 +Sue 417: trees: 8, akitas: 10, perfumes: 3 +Sue 418: samoyeds: 9, goldfish: 2, cars: 1 +Sue 419: akitas: 2, perfumes: 8, trees: 2 +Sue 420: children: 3, goldfish: 6, perfumes: 5 +Sue 421: akitas: 8, perfumes: 2, samoyeds: 6 +Sue 422: vizslas: 10, akitas: 4, pomeranians: 3 +Sue 423: cats: 8, perfumes: 3, trees: 4 +Sue 424: cars: 2, children: 4, pomeranians: 8 +Sue 425: pomeranians: 4, samoyeds: 2, goldfish: 4 +Sue 426: perfumes: 6, cars: 4, goldfish: 4 +Sue 427: akitas: 0, goldfish: 7, perfumes: 5 +Sue 428: perfumes: 4, cars: 3, akitas: 5 +Sue 429: trees: 0, vizslas: 0, goldfish: 1 +Sue 430: perfumes: 4, vizslas: 2, cars: 7 +Sue 431: goldfish: 7, pomeranians: 8, trees: 0 +Sue 432: goldfish: 7, children: 9, trees: 3 +Sue 433: akitas: 1, vizslas: 10, trees: 2 +Sue 434: perfumes: 2, cars: 4, goldfish: 10 +Sue 435: pomeranians: 6, vizslas: 9, trees: 1 +Sue 436: cars: 9, trees: 0, goldfish: 0 +Sue 437: trees: 1, goldfish: 1, vizslas: 8 +Sue 438: goldfish: 7, samoyeds: 8, children: 2 +Sue 439: children: 1, cats: 7, vizslas: 8 +Sue 440: cats: 2, pomeranians: 6, goldfish: 4 +Sue 441: perfumes: 7, cats: 3, vizslas: 6 +Sue 442: akitas: 4, samoyeds: 5, cars: 2 +Sue 443: akitas: 3, perfumes: 3, cats: 9 +Sue 444: perfumes: 10, akitas: 6, trees: 0 +Sue 445: cars: 5, children: 9, perfumes: 8 +Sue 446: vizslas: 10, cars: 3, perfumes: 5 +Sue 447: children: 9, perfumes: 1, cars: 10 +Sue 448: akitas: 0, goldfish: 8, trees: 3 +Sue 449: cars: 7, akitas: 8, children: 3 +Sue 450: cars: 4, akitas: 9, cats: 0 +Sue 451: perfumes: 4, samoyeds: 5, goldfish: 6 +Sue 452: perfumes: 10, akitas: 1, cars: 7 +Sue 453: trees: 1, goldfish: 3, vizslas: 6 +Sue 454: goldfish: 8, pomeranians: 6, trees: 10 +Sue 455: akitas: 5, vizslas: 8, goldfish: 10 +Sue 456: cats: 5, trees: 4, samoyeds: 0 +Sue 457: perfumes: 8, cars: 0, cats: 3 +Sue 458: akitas: 1, trees: 10, vizslas: 2 +Sue 459: vizslas: 6, akitas: 3, children: 10 +Sue 460: perfumes: 7, trees: 9, goldfish: 8 +Sue 461: children: 6, vizslas: 4, perfumes: 5 +Sue 462: vizslas: 6, akitas: 8, perfumes: 9 +Sue 463: goldfish: 8, cars: 4, trees: 10 +Sue 464: pomeranians: 8, cars: 5, vizslas: 0 +Sue 465: cats: 10, goldfish: 7, akitas: 1 +Sue 466: cats: 2, children: 1, cars: 6 +Sue 467: perfumes: 3, samoyeds: 6, cars: 0 +Sue 468: samoyeds: 10, pomeranians: 6, trees: 2 +Sue 469: children: 2, perfumes: 2, pomeranians: 4 +Sue 470: cats: 1, perfumes: 5, vizslas: 9 +Sue 471: vizslas: 5, perfumes: 2, akitas: 7 +Sue 472: samoyeds: 8, goldfish: 6, cats: 1 +Sue 473: goldfish: 10, perfumes: 9, cars: 4 +Sue 474: samoyeds: 0, cars: 4, vizslas: 4 +Sue 475: trees: 2, cars: 7, akitas: 8 +Sue 476: vizslas: 3, perfumes: 5, goldfish: 1 +Sue 477: cats: 7, cars: 4, trees: 1 +Sue 478: vizslas: 8, akitas: 3, goldfish: 0 +Sue 479: cars: 6, cats: 3, perfumes: 2 +Sue 480: goldfish: 1, children: 9, vizslas: 3 +Sue 481: pomeranians: 5, vizslas: 1, cars: 10 +Sue 482: children: 5, perfumes: 5, cats: 1 +Sue 483: perfumes: 2, goldfish: 7, trees: 6 +Sue 484: akitas: 2, goldfish: 4, perfumes: 10 +Sue 485: samoyeds: 3, goldfish: 0, akitas: 1 +Sue 486: trees: 8, vizslas: 9, goldfish: 0 +Sue 487: goldfish: 8, samoyeds: 0, trees: 0 +Sue 488: perfumes: 7, cars: 5, trees: 0 +Sue 489: vizslas: 3, pomeranians: 2, perfumes: 5 +Sue 490: cars: 5, perfumes: 5, akitas: 5 +Sue 491: children: 8, trees: 1, pomeranians: 4 +Sue 492: pomeranians: 0, akitas: 1, vizslas: 8 +Sue 493: akitas: 10, perfumes: 10, samoyeds: 8 +Sue 494: perfumes: 6, vizslas: 4, cats: 6 +Sue 495: children: 6, pomeranians: 5, samoyeds: 4 +Sue 496: vizslas: 1, trees: 5, akitas: 1 +Sue 497: vizslas: 10, perfumes: 10, pomeranians: 3 +Sue 498: samoyeds: 3, trees: 2, cars: 5 +Sue 499: cats: 6, children: 3, perfumes: 0 +Sue 500: pomeranians: 10, cats: 3, vizslas: 5 diff --git a/2015/day16/main.go b/2015/day16/main.go new file mode 100644 index 0000000..492210b --- /dev/null +++ b/2015/day16/main.go @@ -0,0 +1,70 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +var req map[string]int + +func main() { + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + req = make(map[string]int) + req["children"] = 3 + req["cats"] = 7 + req["samoyeds"] = 2 + req["pomeranians"] = 3 + req["akitas"] = 0 + req["vizslas"] = 0 + req["goldfish"] = 5 + req["trees"] = 3 + req["cars"] = 2 + req["perfumes"] = 1 + + for i := range input { + if checkString(input[i]) { + fmt.Println(input[i]) + break + } + } +} + +func checkString(s string) bool { + split := strings.SplitN(s, ": ", 2) + items := strings.Split(split[1], ", ") + for i := range items { + tst := strings.Split(items[i], ": ") + if tst[0] == "trees" || tst[0] == "cats" { + if req[tst[0]] > mustAtoi(tst[1]) { + return false + } + } else if tst[0] == "pomeranians" || tst[0] == "goldfish" { + if req[tst[0]] < mustAtoi(tst[1]) { + return false + } + } else { + if req[tst[0]] != mustAtoi(tst[1]) { + return false + } + } + } + return true +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day16/problem b/2015/day16/problem new file mode 100644 index 0000000..c0e29bd --- /dev/null +++ b/2015/day16/problem @@ -0,0 +1,98 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 16: Aunt Sue --- + + Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. + However, there's a small problem: she signed it "From, Aunt Sue". + + You have 500 Aunts named "Sue". + + So, to avoid sending the card to the wrong person, you need to figure out which Aunt Sue (which + you conveniently number 1 to 500, for sanity) gave you the gift. You open the present and, as + luck would have it, good ol' Aunt Sue got you a My First Crime Scene Analysis Machine! Just + what you wanted. Or needed, as the case may be. + + The My First Crime Scene Analysis Machine (MFCSAM for short) can detect a few specific + compounds in a given sample, as well as how many distinct kinds of those compounds there are. + According to the instructions, these are what the MFCSAM can detect: + + • children, by human DNA age analysis. + • cats. It doesn't differentiate individual breeds. + • Several seemingly random breeds of dog: samoyeds, pomeranians, akitas, and vizslas. + • goldfish. No other kinds of fish. + • trees, all in one group. + • cars, presumably by exhaust or gasoline or something. + • perfumes, which is handy, since many of your Aunts Sue wear a few kinds. + + In fact, many of your Aunts Sue have many of these. You put the wrapping from the gift into the + MFCSAM. It beeps inquisitively at you a few times and then prints out a message on ticker tape: + + children: 3 + cats: 7 + samoyeds: 2 + pomeranians: 3 + akitas: 0 + vizslas: 0 + goldfish: 5 + trees: 3 + cars: 2 + perfumes: 1 + + You make a list of the things you can remember about each Aunt Sue. Things missing from your + list aren't zero - you simply don't remember the value. + + What is the number of the Sue that got you the gift? + + Your puzzle answer was 373. + +--- Part Two --- + + As you're about to send the thank you note, something in the MFCSAM's instructions catches your + eye. Apparently, it has an outdated retroencabulator, and so the output from the machine isn't + exact values - some of them indicate ranges. + + In particular, the cats and trees readings indicates that there are greater than that many (due + to the unpredictable nuclear decay of cat dander and tree pollen), while the pomeranians and + goldfish readings indicate that there are fewer than that many (due to the modial interaction + of magnetoreluctance). + + What is the number of the real Aunt Sue? + + Your puzzle answer was 260. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Samoyed_%28dog%29 + . https://en.wikipedia.org/wiki/Pomeranian_%28dog%29 + . https://en.wikipedia.org/wiki/Akita_%28dog%29 + . https://en.wikipedia.org/wiki/Vizsla + . https://en.wikipedia.org/wiki/Ticker_tape + . https://www.youtube.com/watch?v=RXJKdh1KZ0w + . http://adventofcode.com/ + . http://adventofcode.com/day/16/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Aunt+Sue%22+%2D+Day+16+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16&title=I%27ve+completed+%22Aunt+Sue%22+%2D+Day+16+%2D+Advent+of+Code diff --git a/2015/day17/input b/2015/day17/input new file mode 100644 index 0000000..6b25a72 --- /dev/null +++ b/2015/day17/input @@ -0,0 +1,20 @@ +33 +14 +18 +20 +45 +35 +16 +35 +1 +13 +18 +13 +50 +44 +48 +6 +24 +41 +30 +42 diff --git a/2015/day17/main.go b/2015/day17/main.go new file mode 100644 index 0000000..1fdaef7 --- /dev/null +++ b/2015/day17/main.go @@ -0,0 +1,151 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +type container struct { + value int + name string +} + +func main() { + if len(os.Args) < 2 { + fmt.Println("Usage: day17 ") + os.Exit(1) + } + total := mustAtoi(os.Args[1]) + + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + var containers []container + for i := range input { + val := mustAtoi(input[i]) + // Generate a name for this container + var u int + for j := range containers { + if containers[j].value == val { + u++ + } + } + n := strconv.Itoa(val) + "-" + strconv.Itoa(u) + containers = append(containers, container{value: val, name: n}) + } + fmt.Println("All Containers: ") + fmt.Println(containers) + fmt.Println() + + fmt.Println("Finding Combinations...") + res := findCombis(total, containers) + var final [][]container + fmt.Println() + fmt.Println("Sorting Results...") + for i := 0; i < len(res); i++ { + tst := sortContainers(res[i]) + var dup bool + for j := 0; j < len(final); j++ { + if isEqual(tst, final[j]) { + dup = true + } + } + if !dup { + final = append(final, tst) + } + } + minNum := len(final[0]) + var minConfig [][]container + for i := 0; i < len(final); i++ { + if len(final[i]) < minNum { + minNum = len(final[i]) + } + } + for i := 0; i < len(final); i++ { + if len(final[i]) == minNum { + minConfig = append(minConfig, final[i]) + } + } + + fmt.Print("Total Combinations: ") + fmt.Println(strconv.Itoa(len(final))) + + fmt.Println("Minimum Containers: " + strconv.Itoa(minNum)) + fmt.Println("Num Configurations: " + strconv.Itoa(len(minConfig))) +} + +func findCombis(total int, containers []container) [][]container { + var ret [][]container + + for i := range containers { + if total == containers[i].value { + fmt.Print("O") + ret = append(ret, []container{containers[i]}) + } + if containers[i].value < total { + fmt.Print(".") + bld := []container{containers[i]} + + var pass []container + for j := range containers { + if i != j { + pass = append(pass, containers[j]) + } + } + + tmp := findCombis((total - containers[i].value), pass) + + for idx := 0; idx < len(tmp); idx++ { + tmp[idx] = append(bld, tmp[idx]...) + } + ret = append(ret, tmp...) + } + } + return ret +} + +func sortContainers(c []container) []container { + n := len(c) + swapped := true + for swapped { + swapped = false + for i := 1; i <= n-1; i++ { + if strings.Compare(c[i-1].name, c[i].name) > 0 { + tmp := c[i-1] + c[i-1] = c[i] + c[i] = tmp + swapped = true + } + } + n = n - 1 + } + return c +} + +func isEqual(a, b []container) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i].name != b[i].name { + return false + } + } + return true +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day17/problem b/2015/day17/problem new file mode 100644 index 0000000..f15ca9a --- /dev/null +++ b/2015/day17/problem @@ -0,0 +1,64 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 17: No Such Thing as Too Much --- + + The elves bought too much eggnog again - 150 liters this time. To fit it all into your + refrigerator, you'll need to move it into smaller containers. You take an inventory of the + capacities of the available containers. + + For example, suppose you have containers of size 20, 15, 10, 5, and 5 liters. If you need to + store 25 liters, there are four ways to do it: + + • 15 and 10 + • 20 and 5 (the first 5) + • 20 and 5 (the second 5) + • 15, 5, and 5 + + Filling all containers entirely, how many different combinations of containers can exactly fit + all 150 liters of eggnog? + + Your puzzle answer was 1304. + +--- Part Two --- + + While playing with all the containers in the kitchen, another load of eggnog arrives! The + shipping and receiving department is requesting as many containers as you can spare. + + Find the minimum number of containers that can exactly fit all 150 liters of eggnog. How many + different ways can you fill that number of containers and still hold exactly 150 litres? + + In the example above, the minimum number of containers was two. There were three ways to use + that many containers, and so the answer there would be 3. + + Your puzzle answer was 18. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/17/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&title=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code diff --git a/2015/day17/sample_input b/2015/day17/sample_input new file mode 100644 index 0000000..77f10f3 --- /dev/null +++ b/2015/day17/sample_input @@ -0,0 +1,5 @@ +20 +15 +10 +5 +5 diff --git a/2015/day18/day18.gif b/2015/day18/day18.gif new file mode 100644 index 0000000..5027850 Binary files /dev/null and b/2015/day18/day18.gif differ diff --git a/2015/day18/input b/2015/day18/input new file mode 100644 index 0000000..56534e3 --- /dev/null +++ b/2015/day18/input @@ -0,0 +1,100 @@ +#...##......#......##.##..#...##......##.#.#.###.#.#..#..#......####..#......###.#.#....#..##..###.. +####..#.#...#....#.#####.##.##.#..#.......#....#.##...###.###..#.#.#........#..#.#.##...##..#.####.# +...#..##...#.#.###.#.###..#.##.####.###...#...........#.###..##.#.##.#.###...#.#..###....#.###.#..#. +.#...##...####.#..#.....#..#...#.#.##...#...##..#.#.###....#..###.....##..#.###..###.....##..###...# +..##.#####....##..#.#..##.##..######...#..###.######.....#..##...#.#..##..##..#..#..#..##.#.#.#.#... +.###.###.###...##...##..###..##.###.#.....##..##.#.#########...##..##.#..##.#..##..####..#.#.#.##### +#.#####..###.###.##.##.#...#.#.#.#..#.###...#..##.###.#...####.#..#.#.....###..#..####..#.#.#...##.. +....#...##.....#....####.##.#.###..#.#.##..#.#...##.###.###..#.##..#.#.##..##..#.##.###..#.#.###.### +##.##...#.##...#.#..#.#..#...###...###.#..#..#.#####..###.#......#.....###.#####.#.#..#.#.#.##..#.#. +#.#..#.....#.....##.#..##...###..##...##...###.#.###.#..#.#.###...##..##..#.###...#.#######.#...#.#. +#.#.....####.#..#.##...#.##....#####.###.#.....#####....###..#........##..####...#...#.###....#..### +##.#.##..#.#.##.#.....##.#.....###.####.#..######.....####.#.#..##.#.##...#..#.#.....#.####.#....... +#..#..#.#..#.######.##..##.####.....##.#.##.#.######..#.#....#.#...#.#..#..#.#.###.#..#.#.#..#...### +####..####.#.#.###.....#.#.#.##..#.##.##.##.#..##..##.#.##.....#.#..#.####.....###.#..#.####.#.#..## +###.##..##.#.##..#..##...#.#####.##.#....##.####.#.##....#..###.#.#.##...#.....#.#.#.#.#..##.#.#..#. +......#..####...##.##...#.##.##...##..#..##.###..#...#..##...#.#....###.####...#.##.###.#.##.####.## +..#...#####.#.#..#.##....#..#...#..####.....###...##.###....#..#.###...#........#.#.##..#..#.#.....# +#######.#.#.###.###..######.##..#####.##.###.###....####.#..##.##...###.#..############.#.##....##.# +#.#...##.###.#.###..#.#.#.#.#.#..##..####.#..##.....#.##..#.##...##.#..##..#.#.#....##....##.#..#.#. +..#.#.####.....###..#######.#.#.#.#...##.#####.....##...##...##.###..######.###..#...####.#..###.### +.#.##....#.#.##..##.#.##.##..######...#.....#..#.#.#.#.....#.#..##.#.#.......#######....#.......#... +..###.##.##..##....#.###...#.....##..##......###...##..###.##...##.###.#.#.#.###.###.#.#...###..#... +.##.#.#...#...##.#.#...#..#..#.#...##.#.##...##..#....#.#..##.#..#.#..#.#.....#..#.#...#######.#.##. +...####....#.###.#..###..##...##..#.#.#.###...#..##.##.##..##.#...#..#.##.....#.#........#..#.#.#### +.....##..###...#....#.#.#.#...###.###...#.#...#.#.####....#..####...###..#..######..##.##..###.##### +#####.##..#....###.###....##.....#.#..#....#.#####.##.#.####.#.##...#..###...###..##...#.###.#####.. +###.##..........########.######....####.###.#..##...#.##.####.#.....##..#####..###...#####.....#.#.# +##..#####.##.#.#####.#.##.##..#.##....########.#####.#...#.###.##...#.###.#.#..#....##.#..#...#.#.#. +.##.#....#..#...#..#####..#..##.#......#..#....########...#..#...#.....####.#...##...#.###.#.#..##.# +.##.##.#.##.#.##...#.#.#..##.##.###.#..##..#...###.##.###.#####.#.###..#..###.#...#.###.#...#..#.#.# +.#..#..#.#..#..###..#....###.####.##.#.###.#.##.###.#.##.###.###...###...###.#...####...#.##.##.#.#. +###..##...###...#..##.#..#.#...##....###.##.##..#####....###..#..#....#..###.###.#...#.##...#.#.#..# +#....#.......##.....#.##...#..#.###.#.##..##..#.##..#.###..##.##...#####.#..#####..#####..#####....# +.####.####....###..###.#.##.####.##.#...####.#.###.#.....#...####..#####.###..#.#.###.##.##...##..#. +####..##...##.########...##..###..#..###.##.#.#.#........#.#####.#...#.###.####.#..####..#.#.#....## +###.#..#...###.#..#..#.###...##..###.##.#.#...#..#...####..##....#.#..#..##.#.#...#####.###.#..#.#.# +...##....#.###.#.#..##...##.###.#..#..#......#...#.#..####.#.##..######.####.#...#..#..#..##.#.#.##. +##.####.#...#..#.#.##..##.#.#.###..##...####......#..######.#......#.##.#....##...###.#.#..#......## +#.....#...#######.##.#..#.#...###.#..#.####....#.#.##.#.##...###..#...#.###.##..#.###..#.##...#####. +#####.##...#..#.#.#.......#.##..#####..#####...###..##.#.#..###.#.#####.####..#.#..##...#.##...#.### +.##.#..#######.###.#.####.....##...#.##.#.#..#...##....####......######.#..######.....##########.##. +##...#.#..#.##.###.#.#.#.##.###.##..##.##.##...#.#..###.#######..#.....#####..#....######.#..##..### +.#.#.###.....#..##..#.#..##..#.###...###.#..##...#...#.#####.#.#####..###.#..#...##..#.#..#..####... +.#......##..#.....####.###....##.###.....###.##........#.###.##..#..#.#######.#.######..##..###..... +..##.#.#..#.##...#.###.###...######..#..#.#..#....###.#.#....#..........#...##.##.##.#..##..#.#####. +###.###.#..#.##..##.#..#..##.....##.....#..#######.#..#.#.#.####.###..###.#.#..#.##.##.####.###.#### +#.#.#..#....########.#..#..#...##..#.##..#.#..##..####...##.....#.##.#.#...########..#.###.#..#.#.## +.##.....#...#.#...##.##....###...##..#.####...#..#.#..#..#.##..#.###.##.####.##..####.....##.#.....# +....####.#.##.#.##.#..##.#.######.##.####..#...####.#..###.#.#..#..##.#.#.....##.#####.#.####...#.#. +#..#####.#####.....##....######..##....#..#.#.###.#####.....##.##.####.#...##...#.##.#.#####.##.#... +##.####..###.#....#...#.#.#.#.###.#####.#.####..####...####......##..#..#..#.#.##...########....#... +.###.#.#.#.#..####.##.#..######..#.#.###.....#.#......#.#.#.#..####.##...##.#####.#.##..##..#..#.#.. +.....###...#...#.####.###.#.#.#.#.....#....#.####.###.##.##.##.#######......#.####......#....##..... +##..#..#.#.##..#...#..##.##.##..###.#....##.##....####.#.##.###....#.##.#.#.##...##.###...#..#..#### +...#.#..##..##.#...##.##...#.#......#.#.##..###....####.##...#.#.###.#..#..#.####..##..##..#####.### +.##.##..##########.##...#.##.####.#.#######.##.#.##.##..#...##....########.###..##.##.##.#..##.#.#.# +#####.#....#.##..#.....#......##.##..#.##.###..##.......###..##.#.###.##.###....####.#..#.###..#.#.# +.#...#..#.##....##....#...####....#...#..#...####...########.###.#..##.#.#.##..###..#.#.###.....##.# +##..##.....###......#..###.##.####.##.####.#.#....#..#...#..#.#..#.###.#...#...#..##.##...#..####### +.....##..###..##...#####.#.#.....###.#.#..####...#.#.#..#..####..##.#..###.####.#....##..###....#..# +#.#.##.#....#.#####.#....##...#...##...##....#.#.......#....#..#...###.###.#.####..####....#.##.#.#. +..##...##..###.#.#.##.#..#....#.#.....##.###.#.###.###.....#...#.#..#######.#####..#.###...##......# +#......###..#....#.#..#.###.##.#...##..###.####.#.#....#.##..#.###..##.#..#####..##.###.....#..###.. +##.#.##..##.###.#..##.....#.##.....###....##.####.######.#...#..###....#.#...#.##.....###....#..#.#. +.##.#.#.#.##..#.#.#..##..#.###.####....#..###.######..####.#.....###.##..#...###.#..######.##.#.##.. +...##.####.#..##.#####.##.#...##..#..#...#.#.#.#####...#....#..###...#..#....#.#.##.#.######.#..#### +..#.#.#.#...#.######.#.....#..#.#..###....#.#.########...#....#.#.##..#...##...#.#..#.#.###....##... +#####..#..##..#..##..#..#.#.##.#....#####.####.##.#.###..##..##....#.....#.#####.#...#.#####.##.#.#. +#.#..#####...####.###.###.....####.###.....##...##...#..#..#######.#.##....##..####.....##...#..#..# +#.#.###.#.#..##..#....#.#...#.#.##.##..#.##.....##...#.#..##.......##.#.###..#####.#.##....#.##..... +...#.......#....#.#.####.#.###.###..#....#..##.#..####........#.##..#...#.#...###.#..#.#.#...#...#.. +...##.#####.##.#.###.##.##.#.##..##.#.#.#.#.#.##.#..##...##.#.#..#..##.##.#####.#.###...#####..#..#. +#######.#..#..#....##.#.#..####.#..#..###...#..#.......###.#.#.####....#.###...#.#.###.#.#.#.#..###. +..##.##.#.##.###....###.##.#.###.#...#....#.####..###..###.#.#..#...##.#.#.#..##.###..###.#.##...### +######..######..##..##.#.#.##.##.#..##..#.#.#.##..#.#...#...#.#.#..######.#..#.#.######..#......##.# +#.#####.....#.......#########..###.##...#...##.#.#..#...#####...#...#..#.###.#..#.#...###.#.#.#...#. +#....##....###...##.##.#...##.........##.#.#..#.#.##.#.######.#####..#..###.###.#...#.#.##.######... +#.#...###.#.###.##.#.######.#######.###.##..#.#.#...######.##.####.##..#.#.#.#......##..##.........# +..###..##....#.....##...#.#.###.#.#.....##.#...###.####.#...#...##..##.#.#.####..###...######....#.# +..###.#.##.####.#..#.##....##..#####....#..##.##.#..#######...#.####...##.#.#.##.........#....#....# +.##.#...#.####..#.#...#.##..######.##..##.#.###.##..###.###....##..#.##.##..##.#...###.##.##.###.... +#...###.###.#..#....#.......#..#.....###..#.###.##.##....#.####.#.####.##..##..#..#.....#....##.#.#. +.##.#..#..#.##.......#.####.#######.....#.##.##.#.....#.#..#....######.#..###.##.##.....#.####..##.# +###..#.###.#..####.....##....#..####....#.##.##..#...######.#########...#.#....##...###.#..#.##...#. +#..###..##..#.#.##.###.#.#.##...###.#...##.##..#.###....###..#.#...#.###..######.#..#.###..#..#..#.# +.#........##.#.###..###.#.#.##.....##.##.#.#...##..#.##....###..#.#.#.#.##....#.##..#.#...###...#... +####.####..#....#.#.#..#..##.......##.####...###.##..#.#.##.#..##..######.......##.#.##..#...#.....# +..#..#..###..##.##..######.#..###..###.#.##..##.#..#####.#.#.#.##..#.##..##.##......####.#.......... +...##.##..###.#...###....#.#.#.#.....#.##.....##...#...#......####...##.##....##.#..#.####.#..###.#. +..#.....####.#.###.#####..#..###..#..#.#...#####...###.###....#.###..#...#..#..#.#..#.##..##.#.#.... +..##.#####...###.###.........#....##.####.##..#.#..#.#...#...##.##.##..#.#.##.########......#####... +...###.#.#..#...#.###.###.......##.###.#..#.##########...#..#.#.#.##.#.###...######..#.#...###.##... +.#.#.#######.#..##.##..##...#...####...#..#####.#..##...###.#.#...#.##...#......#..##.####..#.....## +.##.##.#.#......#######..###.....##.#.##..###......#....####...#.###.#.##.#........#..#....##.....## +#...#.###.#.##...##.####....#...#.###..#.#.....#.#....#.#.#.##...#.#..#####.#.#..#..#..#....#...#### +.....##...###......#####..##.##.##...##.#.#####..##...#.#.#.#.###...###.##.####..#.#..#.#..#.####.## +#..#..##.#.##.#.##.#.#.#..###....###.##.#.##.#...#.#..#...#....###.#..#.#.######.#...####..#..##.#.# +#..#.#..#...###.#..##.#...#...##.#......#...#..#..####..##.....#.###...#.#..#.#....#.#####.##.###... +###....#.#..#.#..###..#.##......#...#..#..##.#..###..##..#..#.####..#...########..##.#.##.#.#.#...#. +.#.#.##.##.###..#...#.#....#..#.##..#.#.#.#.##.##.#####...#........####..###..####.#####..#.##.#.##. \ No newline at end of file diff --git a/2015/day18/main.go b/2015/day18/main.go new file mode 100644 index 0000000..b6f05ad --- /dev/null +++ b/2015/day18/main.go @@ -0,0 +1,211 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "os/exec" + "strconv" + "strings" + "time" +) + +var lights [][]bool + +func main() { + ticks := -1 + speed := 2 + var hideSim, lockedCorners bool + for i := range os.Args { + if os.Args[i] == "-help" { + fmt.Println("Usage: day18 [-ticks=] [-speed=]") + fmt.Println("\t-ticks=\tSpecify how many iterations should be performed") + fmt.Println("\t\t\t\tIf not manually set, run forever.") + fmt.Println("\t-speed=\tSpecify how many times/second we iterate") + fmt.Println("\t-hide\t\tHide the actual simulation (for AoC)") + fmt.Println("\t-lockcorners\t\tLock the corner lights 'on' (for AoC pt 2)") + os.Exit(1) + } + if j := strings.Index(os.Args[i], "="); j > 0 { + flagKey := os.Args[i][:j] + flagVal := os.Args[i][j+1:] + if flagKey == "-ticks" { + ticks = mustAtoi(flagVal) + } else if flagKey == "-speed" { + speed = mustAtoi(flagVal) + } + } + if os.Args[i] == "-hide" { + hideSim = true + } + if os.Args[i] == "-lockcorners" { + lockedCorners = true + } + } + if hideSim && ticks == -1 { + // Doesn't make sense to run this configuration + fmt.Println("You asked to run indefinitely and hide the simulation...") + fmt.Println("Refusing to needlessly consume your CPU.") + os.Exit(1) + } + + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + for i := range input { + var bldRow []bool + for j := range input[i] { + bldRow = append(bldRow, (input[i][j] == '#')) + } + lights = append(lights, bldRow) + } + + if !hideSim { + cls() + printLights(lights) + } + for i := 0; i < ticks || ticks == -1; i++ { + if lockedCorners { + lights = lockCorners(lights) + } + lights = tick(lights) + if lockedCorners { + lights = lockCorners(lights) + } + if !hideSim { + cls() + printLights(lights) + } + if !hideSim { + // No reason to sleep if we're hiding the simulation + time.Sleep(time.Second / time.Duration(speed)) + } + } + + fmt.Println("After " + strconv.Itoa(ticks) + " ticks, " + strconv.Itoa(countLights(lights)) + " are on") +} + +func lockCorners(c [][]bool) [][]bool { + c[0][0] = true + c[0][len(c[0])-1] = true + c[len(c)-1][0] = true + c[len(c)-1][len(c[0])-1] = true + return c +} + +func cls() { + cmd := exec.Command("clear") + cmd.Stdout = os.Stdout + cmd.Run() +} + +func printLights(curr [][]bool) { + for i := range curr { + for j := range curr { + if curr[i][j] { + fmt.Print("#") + } else { + fmt.Print(".") + } + } + fmt.Println() + } +} + +func tick(curr [][]bool) [][]bool { + var next [][]bool + for i := range curr { + var bldRow []bool + for j := range curr[i] { + num := checkNeighbors(curr, i, j) + var newVal bool + if curr[i][j] { + // On proc + if num == 2 || num == 3 { + newVal = true + } + } else { + // Off proc + if num == 3 { + newVal = true + } + } + bldRow = append(bldRow, newVal) + } + next = append(next, bldRow) + } + return next +} + +// Returns how many neighbors are on +func checkNeighbors(curr [][]bool, i, j int) int { + var ret int + // nw + if isOn(curr, (i - 1), (j - 1)) { + ret++ + } + // n + if isOn(curr, (i - 1), j) { + ret++ + } + // ne + if isOn(curr, (i - 1), (j + 1)) { + ret++ + } + // w + if isOn(curr, i, (j - 1)) { + ret++ + } + // e + if isOn(curr, i, (j + 1)) { + ret++ + } + // sw + if isOn(curr, (i + 1), (j - 1)) { + ret++ + } + // s + if isOn(curr, (i + 1), j) { + ret++ + } + // se + if isOn(curr, (i + 1), (j + 1)) { + ret++ + } + return ret +} + +func isOn(curr [][]bool, i, j int) bool { + if i < 0 || i >= len(curr) { + return false + } + if j < 0 || j >= len(curr[i]) { + return false + } + return curr[i][j] +} + +func countLights(c [][]bool) int { + var ttl int + for i := range c { + for j := range c[i] { + if c[i][j] { + ttl++ + } + } + } + return ttl +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day18/problem b/2015/day18/problem new file mode 100644 index 0000000..01dec05 --- /dev/null +++ b/2015/day18/problem @@ -0,0 +1,180 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 18: Like a GIF For Your Yard --- + + After the million lights incident, the fire code has gotten stricter: now, at most ten thousand + lights are allowed. You arrange them in a 100x100 grid. + + Never one to let you down, Santa again mails you instructions on the ideal lighting + configuration. With so few lights, he says, you'll have to resort to animation. + + Start by setting your lights to the included initial configuration (your puzzle input). A # + means "on", and a . means "off". + + Then, animate your grid in steps, where each step decides the next configuration based on the + current one. Each light's next state (either on or off) depends on its current state and the + current states of the eight lights adjacent to it (including diagonals). Lights on the edge of + the grid might have fewer than eight neighbors; the missing ones always count as "off". + + For example, in a simplified 6x6 grid, the light marked A has the neighbors numbered 1 through + 8, and the light marked B, which is on an edge, only has the neighbors marked 1 through 5: + + 1B5... + 234... + ...... + ..123. + ..8A4. + ..765. + + The state a light should have next is based on its current state (on or off) plus the number of + neighbors that are on: + + • A light which is on stays on when 2 or 3 neighbors are on, and turns off otherwise. + • A light which is off turns on if exactly 3 neighbors are on, and stays off otherwise. + + All of the lights update simultaneously; they all consider the same current state before moving + to the next. + + Here's a few steps from an example configuration of another 6x6 grid: + + Initial state: + .#.#.# + ...##. + #....# + ..#... + #.#..# + ####.. + + After 1 step: + ..##.. + ..##.# + ...##. + ...... + #..... + #.##.. + + After 2 steps: + ..###. + ...... + ..###. + ...... + .#.... + .#.... + + After 3 steps: + ...#.. + ...... + ...#.. + ..##.. + ...... + ...... + + After 4 steps: + ...... + ...... + ..##.. + ..##.. + ...... + ...... + + After 4 steps, this example has four lights on. + + In your grid of 100x100 lights, given your initial configuration, how many lights are on after + 100 steps? + + Your puzzle answer was 814. + +--- Part Two --- + + You flip the instructions over; Santa goes on to point out that this is all just an + implementation of Conway's Game of Life. At least, it was, until you notice that something's + wrong with the grid of lights you bought: four lights, one in each corner, are stuck on and + can't be turned off. The example above will actually run like this: + + Initial state: + ##.#.# + ...##. + #....# + ..#... + #.#..# + ####.# + + After 1 step: + #.##.# + ####.# + ...##. + ...... + #...#. + #.#### + + After 2 steps: + #..#.# + #....# + .#.##. + ...##. + .#..## + ##.### + + After 3 steps: + #...## + ####.# + ..##.# + ...... + ##.... + ####.# + + After 4 steps: + #.#### + #....# + ...#.. + .##... + #..... + #.#..# + + After 5 steps: + ##.### + .##..# + .##... + .##... + #.#... + ##...# + + After 5 steps, this example now has 17 lights on. + + In your grid of 100x100 lights, given your initial configuration, but with the four corners + always in the on state, how many lights are on after 100 steps? + + Your puzzle answer was 924. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/day/6 + . https://en.wikipedia.org/wiki/Conway's_Game_of_Life + . http://adventofcode.com/ + . http://adventofcode.com/day/18/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&title=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code diff --git a/2015/day18/sample_input b/2015/day18/sample_input new file mode 100644 index 0000000..51dc5ce --- /dev/null +++ b/2015/day18/sample_input @@ -0,0 +1,6 @@ +.#.#.# +...##. +#....# +..#... +#.#..# +####.. \ No newline at end of file diff --git a/2015/day19/input b/2015/day19/input new file mode 100644 index 0000000..b0515c0 --- /dev/null +++ b/2015/day19/input @@ -0,0 +1,45 @@ +Al => ThF +Al => ThRnFAr +B => BCa +B => TiB +B => TiRnFAr +Ca => CaCa +Ca => PB +Ca => PRnFAr +Ca => SiRnFYFAr +Ca => SiRnMgAr +Ca => SiTh +F => CaF +F => PMg +F => SiAl +H => CRnAlAr +H => CRnFYFYFAr +H => CRnFYMgAr +H => CRnMgYFAr +H => HCa +H => NRnFYFAr +H => NRnMgAr +H => NTh +H => OB +H => ORnFAr +Mg => BF +Mg => TiMg +N => CRnFAr +N => HSi +O => CRnFYFAr +O => CRnMgAr +O => HP +O => NRnFAr +O => OTi +P => CaP +P => PTi +P => SiRnFAr +Si => CaSi +Th => ThCa +Ti => BP +Ti => TiTi +e => HF +e => NAl +e => OMg + +CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl diff --git a/2015/day19/main.go b/2015/day19/main.go new file mode 100644 index 0000000..afbabfc --- /dev/null +++ b/2015/day19/main.go @@ -0,0 +1,123 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +func main() { + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, scanner.Text()) + } + + transforms := make(map[string][]string) + var stMolecule string + + for i := range input { + if strings.Contains(input[i], "=>") { + parts := strings.Split(input[i], " => ") + transforms[parts[0]] = append(transforms[parts[0]], parts[1]) + } else if len(input[i]) > 0 { + // Must be the calibration molecule + stMolecule = input[i] + } + } + + fmt.Println("*** CALIBRATION ***") + res := calibrate(stMolecule, transforms) + fmt.Println("Found " + strconv.Itoa(len(res)) + " combinations") + fmt.Println("\n") + fmt.Println("*** MANUFACTURING ***") + backTrans := reverseTransforms(transforms) + manufacture(stMolecule, backTrans, 0) +} + +// stepBack takes an ending string and a reversed list of the transformations +func manufacture(molecule string, transforms map[string][]string, steps int) { + fmt.Println(molecule) + + if molecule == "e" { + fmt.Println("Found in " + strconv.Itoa(steps) + " steps") + os.Exit(0) + } + + for k, v := range transforms { + if strings.Contains(molecule, k) { + for i := range v { + tstVal := strings.Replace(molecule, k, v[i], 1) + manufacture(tstVal, transforms, steps+1) + } + } + } +} + +func reverseTransforms(t map[string][]string) map[string][]string { + ret := make(map[string][]string) + for v := range t { + for j := range t[v] { + ret[t[v][j]] = append(ret[t[v][j]], v) + } + } + return ret +} + +func calibrate(molecule string, transforms map[string][]string) []string { + var ret []string + atoms := getAtomsFromMolecule(molecule) + + for i := range atoms { + // Build a string of atoms before i + start := strings.Join(atoms[:i], "") + // And all after i too + end := strings.Join(atoms[i+1:], "") + // Find all transforms for atoms[i] + if v, ok := transforms[atoms[i]]; ok { + for j := range v { + ret = uniqueInsert(ret, start+v[j]+end) + //ret = append(ret, start+v[j]+end) + } + } + } + return ret +} + +func getAtomsFromMolecule(molecule string) []string { + var atoms []string + var bldAtom string + + for i := range molecule { + if molecule[i] >= 'A' && molecule[i] <= 'Z' { + if len(bldAtom) > 0 { + atoms = append(atoms, bldAtom) + } + bldAtom = string(molecule[i]) + continue + } + bldAtom = bldAtom + string(molecule[i]) + } + return append(atoms, bldAtom) +} + +func uniqueInsert(curr []string, ins string) []string { + for i := range curr { + if curr[i] == ins { + return curr + } + } + return append(curr, ins) +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day19/problem b/2015/day19/problem new file mode 100644 index 0000000..534594d --- /dev/null +++ b/2015/day19/problem @@ -0,0 +1,107 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 19: Medicine for Rudolph --- + + Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very brightly, and he needs + medicine. + + Red-Nosed Reindeer biology isn't similar to regular reindeer biology; Rudolph is going to need + custom-made medicine. Unfortunately, Red-Nosed Reindeer chemistry isn't similar to regular + reindeer chemistry, either. + + The North Pole is equipped with a Red-Nosed Reindeer nuclear fusion/fission plant, capable of + constructing any Red-Nosed Reindeer molecule you need. It works by starting with some input + molecule and then doing a series of replacements, one per step, until it has the right + molecule. + + However, the machine has to be calibrated before it can be used. Calibration involves + determining the number of molecules that can be generated in one step from a given starting + point. + + For example, imagine a simpler machine that supports only the following replacements: + + H => HO + H => OH + O => HH + + Given the replacements above and starting with HOH, the following molecules could be generated: + + • HOOH (via H => HO on the first H). + • HOHO (via H => HO on the second H). + • OHOH (via H => OH on the first H). + • HOOH (via H => OH on the second H). + • HHHH (via O => HH). + + So, in the example above, there are 4 distinct molecules (not five, because HOOH appears twice) + after one replacement from HOH. Santa's favorite molecule, HOHOHO, can become 7 distinct + molecules (over nine replacements: six from H, and three from O). + + The machine replaces without regard for the surrounding characters. For example, given the + string H2O, the transition H => OO would result in OO2O. + + Your puzzle input describes all of the possible replacements and, at the bottom, the medicine + molecule for which you need to calibrate the machine. How many distinct molecules can be + created after all the different ways you can do one replacement on the medicine molecule? + + Your puzzle answer was 518. + +--- Part Two --- + + Now that the machine is calibrated, you're ready to begin molecule fabrication. + + Molecule fabrication always begins with just a single electron, e, and applying replacements + one at a time, just like the ones during calibration. + + For example, suppose you have the following replacements: + + e => H + e => O + H => HO + H => OH + O => HH + + If you'd like to make HOH, you start with e, and then make the following replacements: + + • e => O to get O + • O => HH to get HH + • H => OH (on the second H) to get HOH + + So, you could make HOH after 3 steps. Santa's favorite molecule, HOHOHO, can be made in 6 + steps. + + How long will it take to make the medicine? Given the available replacements and the medicine + molecule in your puzzle input, what is the fewest number of steps to go from e to the medicine + molecule? + + Your puzzle answer was 200. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . http://adventofcode.com/day/19/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Medicine+for+Rudolph%22+%2D+Day+19+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19&title=I%27ve+completed+%22Medicine+for+Rudolph%22+%2D+Day+19+%2D+Advent+of+Code diff --git a/2015/day19/sample_input b/2015/day19/sample_input new file mode 100644 index 0000000..1798c27 --- /dev/null +++ b/2015/day19/sample_input @@ -0,0 +1,5 @@ +H => HO +H => OH +O => HH + +HOH diff --git a/2015/day20/input b/2015/day20/input new file mode 100644 index 0000000..f0d8336 --- /dev/null +++ b/2015/day20/input @@ -0,0 +1 @@ +36000000 diff --git a/2015/day20/main.go b/2015/day20/main.go new file mode 100644 index 0000000..d4a26ed --- /dev/null +++ b/2015/day20/main.go @@ -0,0 +1,112 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +func main() { + if len(os.Args) < 2 { + fmt.Println("Usage: day20 ") + os.Exit(1) + } + numPresents := mustAtoi(os.Args[1]) + + // 831600 was the lowest for part 1 + // Part 2 won't be lower, so... + // 884520 for Part 2? + houseNum := 884500 + k := receivedPresentsPt2(houseNum) + lastFound := houseNum + for { + houseNum = houseNum + 10 + k = receivedPresentsPt2(houseNum) + if k >= (numPresents / 4 * 3) { + fmt.Print("O") + } else if k >= numPresents/2 { + fmt.Print("o") + } else if k >= numPresents/4 { + fmt.Print(".") + } + if k >= numPresents { + fmt.Print(" House number " + strconv.Itoa(houseNum) + " received " + strconv.Itoa(k) + " presents.") + fmt.Println("(" + strconv.Itoa(lastFound-houseNum) + ")") + lastFound = houseNum + } + } + /* + for houseNum > 40000 { //k < numPresents { + if houseNum%100000 == 0 { + fmt.Print("o") + } else if houseNum%1000 == 0 { + fmt.Print(".") + } + houseNum = houseNum - 10 //-- // = houseNum - 360 + k = receivedPresentsPt1(houseNum) + if k >= numPresents { + fmt.Print(" House number " + strconv.Itoa(houseNum) + " received " + strconv.Itoa(k) + " presents.") + fmt.Println("(" + strconv.Itoa(lastFound-houseNum) + ")") + lastFound = houseNum + } + } + */ +} + +func receivedPresentsPt2(house int) int { + var ret int + elves := getFactors(house) + for i := range elves { + if (house / elves[i]) <= 50 { + ret += elves[i] * 11 + } + } + return ret +} + +func receivedPresentsPt1(house int) int { + var ret int + elves := getFactors(house) + for i := range elves { + ret += elves[i] * 10 + } + return ret +} + +func getFactors(n int) []int { + var ret []int + bot := 1 + top := n + for bot < n/2 { + if n%bot == 0 { + top = n / bot + if top == bot { + ret = addUnique(ret, bot) + } else { + ret = addUnique(ret, bot) + ret = addUnique(ret, top) + } + } + bot++ + } + return ret +} + +func addUnique(sl []int, n int) []int { + for i := 0; i < len(sl); i++ { + if sl[i] == n { + return sl + } + } + return append(sl, n) +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day20/problem b/2015/day20/problem new file mode 100644 index 0000000..6461ebd --- /dev/null +++ b/2015/day20/problem @@ -0,0 +1,77 @@ + Advent of Code + + br0xen 40* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 20: Infinite Elves and Infinite Houses --- + + To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door. He sends + them down a street with infinite houses numbered sequentially: 1, 2, 3, 4, 5, and so on. + + Each Elf is assigned a number, too, and delivers presents to houses based on that number: + + • The first Elf (number 1) delivers presents to every house: 1, 2, 3, 4, 5, .... + • The second Elf (number 2) delivers presents to every second house: 2, 4, 6, 8, 10, .... + • Elf number 3 delivers presents to every third house: 3, 6, 9, 12, 15, .... + + There are infinitely many Elves, numbered starting with 1. Each Elf delivers presents equal to + ten times his or her number at each house. + + So, the first nine houses on the street end up like this: + + House 1 got 10 presents. + House 2 got 30 presents. + House 3 got 40 presents. + House 4 got 70 presents. + House 5 got 60 presents. + House 6 got 120 presents. + House 7 got 80 presents. + House 8 got 150 presents. + House 9 got 130 presents. + + The first house gets 10 presents: it is visited only by Elf 1, which delivers 1 * 10 = 10 + presents. The fourth house gets 70 presents, because it is visited by Elves 1, 2, and 4, for a + total of 10 + 20 + 40 = 70 presents. + + What is the lowest house number of the house to get at least as many presents as the number in + your puzzle input? + + Your puzzle answer was 831600. + +--- Part Two --- + + The Elves decide they don't want to visit an infinite number of houses. Instead, each Elf will + stop after delivering presents to 50 houses. To make up for it, they decide to deliver presents + equal to eleven times their number at each house. + + With these changes, what is the new lowest house number of the house to get at least as many + presents as the number in your puzzle input? + + Your puzzle answer was 884520. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + Your puzzle input was 36000000. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/ + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Infinite+Elves+and+Infinite+Houses%22+%2D+Day+20+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20&title=I%27ve+completed+%22Infinite+Elves+and+Infinite+Houses%22+%2D+Day+20+%2D+Advent+of+Code diff --git a/2015/day21/main.go b/2015/day21/main.go new file mode 100644 index 0000000..01c9e32 --- /dev/null +++ b/2015/day21/main.go @@ -0,0 +1,221 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +var enemyHp int +var enemyDmg int +var enemyDef int + +var weaponsAvailable []weapon +var armorAvailable []armor +var ringsAvailable []ring + +var currWeapon, cheapWeapon, highWeapon weapon +var currArmor, cheapArmor, highArmor armor +var currRing1, cheapRing1, highRing1 ring +var currRing2, cheapRing2, highRing2 ring + +// My input: ./day21 100 8 2 +func main() { + if len(os.Args) < 4 || os.Args[1] == "-help" { + fmt.Println("Usage: day21 highest || highest == -1 { + highest = calcCost() + saveHighest() + } + } + } + } + } + } + + if cheapest >= 0 { + fmt.Println("Cheapest Victory: " + itoa(cheapest)) + fmt.Println("Weapon: " + cheapWeapon.name) + fmt.Println("Armor: " + cheapArmor.name) + fmt.Println("Ring1: " + cheapRing1.name) + fmt.Println("Ring2: " + cheapRing2.name) + loadCheapest() + toTheDeath(true) + } else { + fmt.Println("No victory to be had.") + } + fmt.Println() + if highest >= 0 { + fmt.Println("Most Expensive Loss: " + itoa(highest)) + fmt.Println("Weapon: " + highWeapon.name) + fmt.Println("Armor: " + highArmor.name) + fmt.Println("Ring1: " + highRing1.name) + fmt.Println("Ring2: " + highRing2.name) + loadHighest() + toTheDeath(true) + } else { + fmt.Println("No victory to be had.") + } +} + +func loadCheapest() { + currWeapon = cheapWeapon + currArmor = cheapArmor + currRing1 = cheapRing1 + currRing2 = cheapRing2 +} + +func saveCheapest() { + cheapWeapon = currWeapon + cheapArmor = currArmor + cheapRing1 = currRing1 + cheapRing2 = currRing2 +} + +func loadHighest() { + currWeapon = highWeapon + currArmor = highArmor + currRing1 = highRing1 + currRing2 = highRing2 +} + +func saveHighest() { + highWeapon = currWeapon + highArmor = currArmor + highRing1 = currRing1 + highRing2 = currRing2 +} + +func toTheDeath(output bool) bool { + var pHp, pDmg, pDef, eHp, eDmg, eDef int + pHp = 100 + + pDmg += currWeapon.damage + pDmg += currRing1.damage + pDmg += currRing2.damage + pDef += currArmor.defense + pDef += currRing1.defense + pDef += currRing2.defense + + eHp = enemyHp + eDmg = enemyDmg + eDef = enemyDef + + for pHp > 0 && eHp > 0 { + pAtk := pDmg - eDef + if pAtk <= 1 { + pAtk = 1 + } + eHp -= pAtk + eAtk := 1 + if eHp > 0 { + eAtk = eDmg - pDef + if eAtk <= 1 { + eAtk = 1 + } + pHp -= eAtk + } + } + if output { + fmt.Print(itoa(calcCost()) + ": ") + fmt.Print(itoa(pHp) + " to " + itoa(eHp) + " ") + fmt.Println("DMG(" + itoa(pDmg) + ") DEF(" + itoa(pDef) + ") ") + } + return pHp > 0 +} + +func calcCost() int { + return currWeapon.cost + currArmor.cost + currRing1.cost + currRing2.cost +} + +func initShop() { + addWeapon("Dagger", 8, 4) + addWeapon("Shortsword", 10, 5) + addWeapon("Warhammer", 25, 6) + addWeapon("Longsword", 40, 7) + addWeapon("Greataxe", 74, 8) + + addArmor("Leather", 13, 1) + addArmor("Chainmail", 31, 2) + addArmor("Splintmail", 53, 3) + addArmor("Bandedmail", 75, 4) + addArmor("Platemail", 102, 5) + addArmor("No Armor", 0, 0) + + addRing("Damage +1", 25, 1, 0) + addRing("Damage +2", 50, 2, 0) + addRing("Damage +3", 100, 3, 0) + addRing("Defense +1", 20, 0, 1) + addRing("Defense +2", 40, 0, 2) + addRing("Defense +3", 80, 0, 3) + addRing("No Ring 1", 0, 0, 0) + addRing("No Ring 2", 0, 0, 0) +} +func addWeapon(n string, c, dmg int) { + weaponsAvailable = append(weaponsAvailable, + weapon{name: n, cost: c, damage: dmg}) +} +func addArmor(n string, c, def int) { + armorAvailable = append(armorAvailable, + armor{name: n, cost: c, defense: def}) +} +func addRing(n string, c, dmg, def int) { + ringsAvailable = append(ringsAvailable, + ring{name: n, cost: c, damage: dmg, defense: def}) +} + +type weapon struct { + name string + cost, damage int +} + +type armor struct { + name string + cost, defense int +} + +type ring struct { + name string + cost, damage, defense int +} + +func itoa(i int) string { + return strconv.Itoa(i) +} +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day21/problem b/2015/day21/problem new file mode 100644 index 0000000..a3aa5b8 --- /dev/null +++ b/2015/day21/problem @@ -0,0 +1,108 @@ + Advent of Code + + br0xen 42* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 21: RPG Simulator 20XX --- + + Little Henry Case got a new video game for Christmas. It's an RPG, and he's stuck on a boss. + He needs to know what equipment to buy at the shop. He hands you the controller. + + In this game, the player (you) and the enemy (the boss) take turns attacking. The player + always goes first. Each attack reduces the opponent's hit points by at least 1. The first + character at or below 0 hit points loses. + + Damage dealt by an attacker each turn is equal to the attacker's damage score minus the + defender's armor score. An attacker always does at least 1 damage. So, if the attacker has a + damage score of 8, and the defender has an armor score of 3, the defender loses 5 hit points. + If the defender had an armor score of 300, the defender would still lose 1 hit point. + + Your damage score and armor score both start at zero. They can be increased by buying items in + exchange for gold. You start with no items and have as much gold as you need. Your total + damage or armor is equal to the sum of those stats from all of your items. You have 100 hit + points. + + Here is what the item shop is selling: + + Weapons: Cost Damage Armor + Dagger 8 4 0 + Shortsword 10 5 0 + Warhammer 25 6 0 + Longsword 40 7 0 + Greataxe 74 8 0 + + Armor: Cost Damage Armor + Leather 13 0 1 + Chainmail 31 0 2 + Splintmail 53 0 3 + Bandedmail 75 0 4 + Platemail 102 0 5 + + Rings: Cost Damage Armor + Damage +1 25 1 0 + Damage +2 50 2 0 + Damage +3 100 3 0 + Defense +1 20 0 1 + Defense +2 40 0 2 + Defense +3 80 0 3 + + You must buy exactly one weapon; no dual-wielding. Armor is optional, but you can't use more + than one. You can buy 0-2 rings (at most one for each hand). You must use any items you buy. + The shop only has one of each item, so you can't buy, for example, two rings of Damage +3. + + For example, suppose you have 8 hit points, 5 damage, and 5 armor, and that the boss has 12 + hit points, 7 damage, and 2 armor: + + • The player deals 5-2 = 3 damage; the boss goes down to 9 hit points. + • The boss deals 7-5 = 2 damage; the player goes down to 6 hit points. + • The player deals 5-2 = 3 damage; the boss goes down to 6 hit points. + • The boss deals 7-5 = 2 damage; the player goes down to 4 hit points. + • The player deals 5-2 = 3 damage; the boss goes down to 3 hit points. + • The boss deals 7-5 = 2 damage; the player goes down to 2 hit points. + • The player deals 5-2 = 3 damage; the boss goes down to 0 hit points. + + In this scenario, the player wins! (Barely.) + + You have 100 hit points. The boss's actual stats are in your puzzle input. What is the least + amount of gold you can spend and still win the fight? + + Your puzzle answer was 91. + +--- Part Two --- + + Turns out the shopkeeper is working with the boss, and can persuade you to buy whatever items + he wants. The other rules still apply, and he still only has one of each item. + + What is the most amount of gold you can spend and still lose the fight? + + Your puzzle answer was 158. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Role-playing_video_game + . https://en.wikipedia.org/wiki/Game_controller + . http://adventofcode.com/ + . http://adventofcode.com/day/21/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&title=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code diff --git a/2015/day22/main.go b/2015/day22/main.go new file mode 100644 index 0000000..4c198ca --- /dev/null +++ b/2015/day22/main.go @@ -0,0 +1,227 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +const ( + playerTurn = iota + bossTurn +) + +type state struct { + bossHp int + bossDmg int + playerHp int + playerMp int + playerDef int + shield int + poison int + recharge int + manaSpent int + move int +} + +type spell struct { + name string + mpCost int + damage int + heal int + duration int +} + +var minMp int +var spellBook []spell +var stateStack []state + +func main() { + minMp = -1 + initSpellBook() + if len(os.Args) == 2 && os.Args[1] == "-help" { + fmt.Println("Usage: day22 [ [ ]]") + os.Exit(1) + } + //debugMode = true + eHp := 71 + eDmg := 10 + if len(os.Args) >= 3 { + eHp = mustAtoi(os.Args[1]) + eDmg = mustAtoi(os.Args[2]) + } + pHp := 50 + pMp := 500 + if len(os.Args) == 5 { + pHp = mustAtoi(os.Args[3]) + pMp = mustAtoi(os.Args[4]) + } + s := state{ + bossHp: eHp, + bossDmg: eDmg, + playerHp: pHp, + playerMp: pMp, + playerDef: 0, + shield: 0, + poison: 0, + recharge: 0, + manaSpent: 0, + move: playerTurn, + } + stateStack = append(stateStack, s) + for len(stateStack) > 0 { + var wrk state + wrk, stateStack = stateStack[0], stateStack[1:] + // Hard Mode + if wrk.move == playerTurn { + wrk.playerHp-- + } + wrk.playerDef = 0 + if wrk.shield > 0 { + wrk.playerDef = 7 + } + if wrk.poison > 0 { + wrk.bossHp -= 3 + } + if wrk.recharge > 0 { + wrk.playerMp += 101 + } + wrk = decrementTimers(wrk) + if wrk.playerHp <= 0 || (wrk.manaSpent > minMp && minMp != -1) { + // Unsuccessful path + continue + } + if wrk.bossHp <= 0 { + // Successful path! + if minMp == -1 || minMp > wrk.manaSpent { + minMp = wrk.manaSpent + } + continue + } + if wrk.move == bossTurn { + wrk.move = playerTurn + atk := 1 + if wrk.bossDmg-wrk.playerDef > 1 { + atk = wrk.bossDmg - wrk.playerDef + } + wrk.playerHp -= atk + stateStack = append([]state{wrk}, stateStack...) + } else { + wrk.move = bossTurn + for i := range spellBook { + tstSpell := spellBook[i] + if tstSpell.mpCost >= wrk.playerMp { + continue + } + nextState, ok := castSpell(wrk, tstSpell) + if ok { + stateStack = append([]state{nextState}, stateStack...) + } + } + } + } + fmt.Printf("%d\n", minMp) +} + +func castSpell(w state, s spell) (state, bool) { + if s.name == "Magic Missile" || s.name == "Drain" { + w.bossHp -= s.damage + w.playerHp += s.heal + } else if s.name == "Shield" { + if w.shield > 0 { + return w, false + } + w.shield = s.duration + } else if s.name == "Poison" { + if w.poison > 0 { + return w, false + } + w.poison = s.duration + } else if s.name == "Recharge" { + if w.recharge > 0 { + return w, false + } + w.recharge = s.duration + } + w.playerMp -= s.mpCost + w.manaSpent += s.mpCost + return w, true +} + +func copyState(w state) state { + ret := state{ + bossHp: w.bossHp, + bossDmg: w.bossDmg, + playerHp: w.playerHp, + playerMp: w.playerMp, + playerDef: w.playerDef, + shield: w.shield, + poison: w.poison, + recharge: w.recharge, + manaSpent: w.manaSpent, + move: w.move, + } + return ret +} + +func printState(w state) { + if w.move == playerTurn { + fmt.Println("*** Player Turn ***") + } else { + fmt.Println("*** Boss Turn ***") + } + fmt.Printf("Player - HP(%d) MP(%d)\n", w.playerHp, w.playerMp) + fmt.Printf("Boss - HP(%d) DMG(%d)\n", w.bossHp, w.bossDmg) + fmt.Printf("Shield(%d); Poison(%d); Recharge(%d)\n", w.shield, w.poison, w.recharge) + fmt.Printf("Mana Used: %d\n", w.manaSpent) + fmt.Println() +} + +func decrementTimers(w state) state { + w.shield-- + w.poison-- + w.recharge-- + return w +} + +func initSpellBook() { + spellBook = append(spellBook, spell{ + name: "Magic Missile", + mpCost: 53, + damage: 4, + }) + spellBook = append(spellBook, spell{ + name: "Drain", + mpCost: 73, + damage: 2, + heal: 2, + }) + spellBook = append(spellBook, spell{ + name: "Shield", + mpCost: 113, + duration: 6, + }) + spellBook = append(spellBook, spell{ + name: "Poison", + mpCost: 173, + duration: 6, + }) + spellBook = append(spellBook, spell{ + name: "Recharge", + mpCost: 229, + duration: 5, + }) +} + +func itoa(i int) string { + return strconv.Itoa(i) +} +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day22/problem b/2015/day22/problem new file mode 100644 index 0000000..b6325f4 --- /dev/null +++ b/2015/day22/problem @@ -0,0 +1,161 @@ + Advent of Code + + br0xen 44* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 22: Wizard Simulator 20XX --- + + Little Henry Case decides that defeating bosses with swords and stuff is boring. Now he's + playing the game with a wizard. Of course, he gets stuck on another boss and needs your help + again. + + In this version, combat still proceeds with the player and the boss taking alternating turns. + The player still goes first. Now, however, you don't get any equipment; instead, you must + choose one of your spells to cast. The first character at or below 0 hit points loses. + + Since you're a wizard, you don't get to wear armor, and you can't attack normally. However, + since you do magic damage, your opponent's armor is ignored, and so the boss effectively has + zero armor as well. As before, if armor (from a spell, in this case) would reduce damage below + 1, it becomes 1 instead - that is, the boss' attacks always deal at least 1 damage. + + On each of your turns, you must select one of your spells to cast. If you cannot afford to + cast any spell, you lose. Spells cost mana; you start with 500 mana, but have no maximum + limit. You must have enough mana to cast a spell, and its cost is immediately deducted when + you cast it. Your spells are Magic Missile, Drain, Shield, Poison, and Recharge. + + • Magic Missile costs 53 mana. It instantly does 4 damage. + • Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points. + • Shield costs 113 mana. It starts an effect that lasts for 6 turns. While it is active, + your armor is increased by 7. + • Poison costs 173 mana. It starts an effect that lasts for 6 turns. At the start of each + turn while it is active, it deals the boss 3 damage. + • Recharge costs 229 mana. It starts an effect that lasts for 5 turns. At the start of each + turn while it is active, it gives you 101 new mana. + + Effects all work the same way. Effects apply at the start of both the player's turns and the + boss' turns. Effects are created with a timer (the number of turns they last); at the start of + each turn, after they apply any effect they have, their timer is decreased by one. If this + decreases the timer to zero, the effect ends. You cannot cast a spell that would start an + effect which is already active. However, effects can be started on the same turn they end. + + For example, suppose the player has 10 hit points and 250 mana, and that the boss has 13 hit + points and 8 damage: + + -- Player turn -- + - Player has 10 hit points, 0 armor, 250 mana + - Boss has 13 hit points + Player casts Poison. + + -- Boss turn -- + - Player has 10 hit points, 0 armor, 77 mana + - Boss has 13 hit points + Poison deals 3 damage; its timer is now 5. + Boss attacks for 8 damage. + + -- Player turn -- + - Player has 2 hit points, 0 armor, 77 mana + - Boss has 10 hit points + Poison deals 3 damage; its timer is now 4. + Player casts Magic Missile, dealing 4 damage. + + -- Boss turn -- + - Player has 2 hit points, 0 armor, 24 mana + - Boss has 3 hit points + Poison deals 3 damage. This kills the boss, and the player wins. + + Now, suppose the same initial conditions, except that the boss has 14 hit points instead: + + -- Player turn -- + - Player has 10 hit points, 0 armor, 250 mana + - Boss has 14 hit points + Player casts Recharge. + + -- Boss turn -- + - Player has 10 hit points, 0 armor, 21 mana + - Boss has 14 hit points + Recharge provides 101 mana; its timer is now 4. + Boss attacks for 8 damage! + + -- Player turn -- + - Player has 2 hit points, 0 armor, 122 mana + - Boss has 14 hit points + Recharge provides 101 mana; its timer is now 3. + Player casts Shield, increasing armor by 7. + + -- Boss turn -- + - Player has 2 hit points, 7 armor, 110 mana + - Boss has 14 hit points + Shield's timer is now 5. + Recharge provides 101 mana; its timer is now 2. + Boss attacks for 8 - 7 = 1 damage! + + -- Player turn -- + - Player has 1 hit point, 7 armor, 211 mana + - Boss has 14 hit points + Shield's timer is now 4. + Recharge provides 101 mana; its timer is now 1. + Player casts Drain, dealing 2 damage, and healing 2 hit points. + + -- Boss turn -- + - Player has 3 hit points, 7 armor, 239 mana + - Boss has 12 hit points + Shield's timer is now 3. + Recharge provides 101 mana; its timer is now 0. + Recharge wears off. + Boss attacks for 8 - 7 = 1 damage! + + -- Player turn -- + - Player has 2 hit points, 7 armor, 340 mana + - Boss has 12 hit points + Shield's timer is now 2. + Player casts Poison. + + -- Boss turn -- + - Player has 2 hit points, 7 armor, 167 mana + - Boss has 12 hit points + Shield's timer is now 1. + Poison deals 3 damage; its timer is now 5. + Boss attacks for 8 - 7 = 1 damage! + + -- Player turn -- + - Player has 1 hit point, 7 armor, 167 mana + - Boss has 9 hit points + Shield's timer is now 0. + Shield wears off, decreasing armor by 7. + Poison deals 3 damage; its timer is now 4. + Player casts Magic Missile, dealing 4 damage. + + -- Boss turn -- + - Player has 1 hit point, 0 armor, 114 mana + - Boss has 2 hit points + Poison deals 3 damage. This kills the boss, and the player wins. + + You start with 50 hit points and 500 mana points. The boss's actual stats are in your puzzle + input. What is the least amount of mana you can spend and still win the fight? (Do not include + mana recharge effects as "spending" negative mana.) + + To begin, get your puzzle input. + + Answer: _____________________ [ [Submit] ] + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/day/21 + . http://adventofcode.com/day/22/input + . https://twitter.com/intent/tweet?text=%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&title=%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code diff --git a/2015/day23/input b/2015/day23/input new file mode 100644 index 0000000..1ff192d --- /dev/null +++ b/2015/day23/input @@ -0,0 +1,48 @@ +jio a, +22 +inc a +tpl a +tpl a +tpl a +inc a +tpl a +inc a +tpl a +inc a +inc a +tpl a +inc a +inc a +tpl a +inc a +inc a +tpl a +inc a +inc a +tpl a +jmp +19 +tpl a +tpl a +tpl a +tpl a +inc a +inc a +tpl a +inc a +tpl a +inc a +inc a +tpl a +inc a +inc a +tpl a +inc a +tpl a +tpl a +jio a, +8 +inc b +jie a, +4 +tpl a +inc a +jmp +2 +hlf a +jmp -7 \ No newline at end of file diff --git a/2015/day23/main.go b/2015/day23/main.go new file mode 100644 index 0000000..30f28e3 --- /dev/null +++ b/2015/day23/main.go @@ -0,0 +1,103 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +var registers map[string]int + +func main() { + registers = make(map[string]int) + if len(os.Args) > 1 { + if os.Args[1] == "-help" { + fmt.Println("Usage: day23 [register presets]") + fmt.Println(" Register presets are given in the form:") + fmt.Println(" name=value") + fmt.Println(" If more than one, separate with spaces.") + fmt.Println(" If none are given, all registers start at 0") + os.Exit(1) + } + for i := range os.Args { + if strings.Contains(os.Args[i], "=") { + presets := strings.Split(os.Args[i], "=") + registers[presets[0]] = mustAtoi(presets[1]) + } + } + } + var input []string + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + input = append(input, strings.ToLower(scanner.Text())) + } + // We manually manage i + var i, cnt int + for i < len(input) { + printRegisters() + fmt.Print(" ") + cnt++ + fmt.Print(input[i]) + parts := strings.Split(input[i], " ") + switch parts[0] { + case "hlf": + registers[parts[1]] = registers[parts[1]] / 2 + i++ + case "tpl": + registers[parts[1]] = registers[parts[1]] * 3 + i++ + case "inc": + registers[parts[1]]++ + i++ + case "jmp": + i += mustAtoi(parts[1]) + case "jie": + parts[1] = string(parts[1][len(parts[1])-2]) + if registers[parts[1]]%2 == 0 { + i += mustAtoi(parts[2]) + } else { + i++ + } + case "jio": + parts[1] = string(parts[1][len(parts[1])-2]) + if registers[parts[1]] == 1 { + i += mustAtoi(parts[2]) + } else { + i++ + } + } + fmt.Print(" ") + printRegistersLn() + } + printRegistersLn() +} + +func printRegistersLn() { + printRegisters() + fmt.Println() +} + +func printRegisters() { + fmt.Print("[") + for k := range registers { + printRegister(k) + fmt.Print(" ") + } + fmt.Print("]") +} + +func printRegister(n string) { + fmt.Print(n + ": " + strconv.Itoa(registers[n])) +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day23/problem b/2015/day23/problem new file mode 100644 index 0000000..5866c5c --- /dev/null +++ b/2015/day23/problem @@ -0,0 +1,78 @@ + Advent of Code + + br0xen 43* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 23: Opening the Turing Lock --- + + Little Jane Marie just got her very first computer for Christmas from some unknown benefactor. + It comes with instructions and an example program, but the computer itself seems to be + malfunctioning. She's curious what the program does, and would like you to help her run it. + + The manual explains that the computer supports two registers and six instructions (truly, it + goes on to remind the reader, a state-of-the-art technology). The registers are named a and b, + can hold any non-negative integer, and begin with a value of 0. The instructions are as + follows: + + • hlf r sets register r to half its current value, then continues with the next instruction. + • tpl r sets register r to triple its current value, then continues with the next + instruction. + • inc r increments register r, adding 1 to it, then continues with the next instruction. + • jmp offset is a jump; it continues with the instruction offset away relative to itself. + • jie r, offset is like jmp, but only jumps if register r is even ("jump if even"). + • jio r, offset is like jmp, but only jumps if register r is 1 ("jump if one", not odd). + + All three jump instructions work with an offset relative to that instruction. The offset is + always written with a prefix + or - to indicate the direction of the jump (forward or + backward, respectively). For example, jmp +1 would simply continue with the next instruction, + while jmp +0 would continuously jump back to itself forever. + + The program exits when it tries to run an instruction beyond the ones defined. + + For example, this program sets a to 2, because the jio instruction causes it to skip the tpl + instruction: + + inc a + jio a, +2 + tpl a + inc a + + What is the value in register b when the program in your puzzle input is finished executing? + + Your puzzle answer was 255. + + The first half of this puzzle is complete! It provides one gold star: * + +--- Part Two --- + + The unknown benefactor is very thankful for releasi-- er, helping little Jane Marie with her + computer. Definitely not to distract you, what is the value in register b after the program is + finished executing if register a starts as 1 instead? + + Although it hasn't changed, you can still get your puzzle input. + + Answer: _____________________ [ [Submit] ] + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Processor_register + . https://en.wikipedia.org/wiki/Instruction_set + . https://en.wikipedia.org/wiki/Natural_number + . http://adventofcode.com/day/23/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Opening+the+Turing+Lock%22+%2D+Day+23+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23&title=I%27ve+completed+Part+One+of+%22Opening+the+Turing+Lock%22+%2D+Day+23+%2D+Advent+of+Code diff --git a/2015/day24/input b/2015/day24/input new file mode 100644 index 0000000..e204f7d --- /dev/null +++ b/2015/day24/input @@ -0,0 +1,28 @@ +1 +3 +5 +11 +13 +17 +19 +23 +29 +31 +37 +41 +43 +47 +53 +59 +67 +71 +73 +79 +83 +89 +97 +101 +103 +107 +109 +113 diff --git a/2015/day24/main.go b/2015/day24/main.go new file mode 100644 index 0000000..501f93a --- /dev/null +++ b/2015/day24/main.go @@ -0,0 +1,142 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "strings" +) + +var pkgWeights []int64 + +func main() { + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + pkgWeights = append(pkgWeights, int64(mustAtoi(strings.ToLower(scanner.Text())))) + } + // Sort the weights, in the case of our input, no need. + totalWeight := weighPackages(pkgWeights) + // For Part 1: + //splitWeight := totalWeight / 3 + // For Part 2: + splitWeight := totalWeight / 4 + fmt.Printf("Balanced at %d\n", splitWeight) + // Now find the fewest number of packages that are that weight + result := tryPackages([]int64{}, pkgWeights, splitWeight) + fmt.Println("*** RESULT ***") + //result = makeUnique(result) + lowestQE := int64(-1) + shortest := -1 + for i := range result { + if len(result[i]) <= shortest || shortest == -1 { + fmt.Print(result[i]) + fmt.Printf(" L:%d", len(result[i])) + fmt.Printf(" QE:%d\n", getQE(result[i])) + shortest = len(result[i]) + if getQE(result[i]) < lowestQE || lowestQE == -1 { + lowestQE = getQE(result[i]) + } + } + } + fmt.Println() + fmt.Printf("%d\n", lowestQE) +} + +func tryPackages(pkgs []int64, rem []int64, targ int64) [][]int64 { + // Go through all packages in 'rem' and find the combination + // That results in the least total number of packages + var findRet [][]int64 + fewest := -1 + if len(pkgs) > fewest && fewest != -1 { + return findRet + } + for i := len(rem) - 1; i >= 0; i-- { + t := targ - weighPackages(pkgs) + if rem[i] <= t { + tryPkgs := append(pkgs, rem[i]) + if weighPackages(tryPkgs) == targ { + //if len(tryPkgs) <= fewest || fewest == -1 { + findRet = append(findRet, tryPkgs) + // fewest = len(tryPkgs) + //} + } + // Not there yet... Recurse + rem = rem[:i] + res := tryPackages(tryPkgs, rem, targ) + for i := range res { + if weighPackages(res[i]) == targ { + //if len(res[i]) <= fewest || fewest == -1 { + findRet = append(findRet, res[i]) + // fewest = len(res[i]) + //} + } + } + } + } + return findRet +} + +func getQE(pkgs []int64) int64 { + var totalQE int64 + for i := range pkgs { + if totalQE == 0 { + totalQE = int64(pkgs[i]) + } else { + totalQE = totalQE * int64(pkgs[i]) + } + } + return totalQE +} + +func weighPackages(pkgs []int64) int64 { + var totalWeight int64 + for i := range pkgs { + totalWeight += pkgs[i] + } + return totalWeight +} + +func makeUnique(s [][]int64) [][]int64 { + var ret [][]int64 + for i := range s { + var found bool + // Check if s[i] is already in ret + for j := range ret { + if isSame(ret[j], s[i]) { + found = true + break + } + } + if !found { + ret = append(ret, s[i]) + } + } + return ret +} + +func isSame(s1 []int64, s2 []int64) bool { + if len(s1) != len(s2) { + return false + } + for i := range s1 { + if s1[i] != s2[i] { + return false + } + } + return true +} + +func itoa(i int) string { + return strconv.Itoa(i) +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day24/problem b/2015/day24/problem new file mode 100644 index 0000000..5b77d93 --- /dev/null +++ b/2015/day24/problem @@ -0,0 +1,116 @@ + Advent of Code + + br0xen 50* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 24: It Hangs in the Balance --- + + It's Christmas Eve, and Santa is loading up the sleigh for this year's deliveries. However, + there's one small problem: he can't get the sleigh to balance. If it isn't balanced, he can't + defy physics, and nobody gets presents this year. + + No pressure. + + Santa has provided you a list of the weights of every package he needs to fit on the sleigh. + The packages need to be split into three groups of exactly the same weight, and every package + has to fit. The first group goes in the passenger compartment of the sleigh, and the second + and third go in containers on either side. Only when all three groups weigh exactly the same + amount will the sleigh be able to fly. Defying physics has rules, you know! + + Of course, that's not the only problem. The first group - the one going in the passenger + compartment - needs as few packages as possible so that Santa has some legroom left over. It + doesn't matter how many packages are in either of the other two groups, so long as all of the + groups weigh the same. + + Furthermore, Santa tells you, if there are multiple ways to arrange the packages such that the + fewest possible are in the first group, you need to choose the way where the first group has + the smallest quantum entanglement to reduce the chance of any "complications". The quantum + entanglement of a group of packages is the product of their weights, that is, the value you + get when you multiply their weights together. Only consider quantum entanglement if the first + group has the fewest possible number of packages in it and all groups weigh the same amount. + + For example, suppose you have ten packages with weights 1 through 5 and 7 through 11. For this + situation, some of the unique first groups, their quantum entanglements, and a way to divide + the remaining packages are as follows: + + Group 1; Group 2; Group 3 + 11 9 (QE= 99); 10 8 2; 7 5 4 3 1 + 10 9 1 (QE= 90); 11 7 2; 8 5 4 3 + 10 8 2 (QE=160); 11 9; 7 5 4 3 1 + 10 7 3 (QE=210); 11 9; 8 5 4 2 1 + 10 5 4 1 (QE=200); 11 9; 8 7 3 2 + 10 5 3 2 (QE=300); 11 9; 8 7 4 1 + 10 4 3 2 1 (QE=240); 11 9; 8 7 5 + 9 8 3 (QE=216); 11 7 2; 10 5 4 1 + 9 7 4 (QE=252); 11 8 1; 10 5 3 2 + 9 5 4 2 (QE=360); 11 8 1; 10 7 3 + 8 7 5 (QE=280); 11 9; 10 4 3 2 1 + 8 5 4 3 (QE=480); 11 9; 10 7 2 1 + 7 5 4 3 1 (QE=420); 11 9; 10 8 2 + + Of these, although 10 9 1 has the smallest quantum entanglement (90), the configuration with + only two packages, 11 9, in the passenger compartment gives Santa the most legroom and wins. + In this situation, the quantum entanglement for the ideal configuration is therefore 99. Had + there been two configurations with only two packages in the first group, the one with the + smaller quantum entanglement would be chosen. + + What is the quantum entanglement of the first group of packages in the ideal configuration? + + Your puzzle answer was 10439961859. + +--- Part Two --- + + That's weird... the sleigh still isn't balancing. + + "Ho ho ho", Santa muses to himself. "I forgot the trunk". + + Balance the sleigh again, but this time, separate the packages into four groups instead of + three. The other constraints still apply. + + Given the example packages above, this would be some of the new unique first groups, their + quantum entanglements, and one way to divide the remaining packages: + + 11 4 (QE=44); 10 5; 9 3 2 1; 8 7 + 10 5 (QE=50); 11 4; 9 3 2 1; 8 7 + 9 5 1 (QE=45); 11 4; 10 3 2; 8 7 + 9 4 2 (QE=72); 11 3 1; 10 5; 8 7 + 9 3 2 1 (QE=54); 11 4; 10 5; 8 7 + 8 7 (QE=56); 11 4; 10 5; 9 3 2 1 + + Of these, there are three arrangements that put the minimum (two) number of packages in the + first group: 11 4, 10 5, and 8 7. Of these, 11 4 has the lowest quantum entanglement, and so + it is selected. + + Now, what is the quantum entanglement of the first group of packages in the ideal + configuration? + + Your puzzle answer was 72050269. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, all that is left is for you to admire your advent calendar. + + If you still want to see it, you can get your puzzle input. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . https://en.wikipedia.org/wiki/Product_%28mathematics%29 + . http://adventofcode.com/ + . http://adventofcode.com/day/24/input + . https://twitter.com/intent/tweet?text=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&title=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code diff --git a/2015/day24/sample_input b/2015/day24/sample_input new file mode 100644 index 0000000..957cf3a --- /dev/null +++ b/2015/day24/sample_input @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +7 +8 +9 +10 +11 \ No newline at end of file diff --git a/2015/day25/input b/2015/day25/input new file mode 100644 index 0000000..c5c38e6 --- /dev/null +++ b/2015/day25/input @@ -0,0 +1 @@ +To continue, please consult the code grid in the manual. Enter the code at row 2947, column 3029. diff --git a/2015/day25/main.go b/2015/day25/main.go new file mode 100644 index 0000000..c3b0b2e --- /dev/null +++ b/2015/day25/main.go @@ -0,0 +1,55 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +func main() { + if len(os.Args) < 2 || os.Args[1] == "-help" { + fmt.Println("Usage: day25 ") + fmt.Println(" or: day25 ") + } + row := mustAtoi(os.Args[1]) + if len(os.Args) == 2 { + fmt.Printf("%d\n", genCodeNum(row)) + os.Exit(0) + } + // Must be row/col request + col := mustAtoi(os.Args[2]) + fmt.Printf("%d\n", genCodeNum(codeNumFromRowCol(row, col))) +} + +func codeNumFromRowCol(r int, c int) int { + if r == 1 { + if c == 1 { + return 1 + } + return c + codeNumFromRowCol(r, c-1) + } + if c == 1 { + return codeNumFromRowCol(1, (r-1)) + 1 + } + return codeNumFromRowCol((r+1), (c-1)) + 1 +} + +func genCodeNum(i int) int64 { + ret := int64(20151125) + for i > 1 { + ret *= 252533 + ret = ret % 33554393 + i-- + } + return ret +} + +func mustAtoi(s string) int { + var i int + var err error + if i, err = strconv.Atoi(s); err != nil { + fmt.Println("Tried to atoi " + s) + os.Exit(1) + } + return i +} diff --git a/2015/day25/problem b/2015/day25/problem new file mode 100644 index 0000000..88990ea --- /dev/null +++ b/2015/day25/problem @@ -0,0 +1,106 @@ + Advent of Code + + br0xen 46* + + • [About] + • [Stats] + • [Leaderboard] + • [Settings] + • [Log out] + +--- Day 25: Let It Snow --- + + Merry Christmas! Santa is booting up his weather machine; looks like you might get a white + Christmas after all. + + The weather machine beeps! On the console of the machine is a copy protection message asking + you to enter a code from the instruction manual. Apparently, it refuses to run unless you give + it that code. No problem; you'll just look up the code in the-- + + "Ho ho ho", Santa ponders aloud. "I can't seem to find the manual." + + You look up the support number for the manufacturer and give them a call. Good thing, too - + that 49th star wasn't going to earn itself. + + "Oh, that machine is quite old!", they tell you. "That model went out of support six minutes + ago, and we just finished shredding all of the manuals. I bet we can find you the code + generation algorithm, though." + + After putting you on hold for twenty minutes (your call is very important to them, it reminded + you repeatedly), they finally find an engineer that remembers how the code system works. + + The codes are printed on an infinite sheet of paper, starting in the top-left corner. The + codes are filled in by diagonals: starting with the first row with an empty first box, the + codes are filled in diagonally up and to the right. This process repeats until the infinite + paper is covered. So, the first few codes are filled in in this order: + + | 1 2 3 4 5 6 + ---+---+---+---+---+---+---+ + 1 | 1 3 6 10 15 21 + 2 | 2 5 9 14 20 + 3 | 4 8 13 19 + 4 | 7 12 18 + 5 | 11 17 + 6 | 16 + + For example, the 12th code would be written to row 4, column 2; the 15th code would be written + to row 1, column 5. + + The voice on the other end of the phone continues with how the codes are actually generated. + The first code is 20151125. After that, each code is generated by taking the previous one, + multiplying it by 252533, and then keeping the remainder from dividing that value by 33554393. + + So, to find the second code (which ends up in row 2, column 1), start with the previous value, + 20151125. Multiply it by 252533 to get 5088824049625. Then, divide that by 33554393, which + leaves a remainder of 31916031. That remainder is the second code. + + "Oh!", says the voice. "It looks like we missed a scrap from one of the manuals. Let me read + it to you." You write down his numbers: + + | 1 2 3 4 5 6 + ---+---------+---------+---------+---------+---------+---------+ + 1 | 20151125 18749137 17289845 30943339 10071777 33511524 + 2 | 31916031 21629792 16929656 7726640 15514188 4041754 + 3 | 16080970 8057251 1601130 7981243 11661866 16474243 + 4 | 24592653 32451966 21345942 9380097 10600672 31527494 + 5 | 77061 17552253 28094349 6899651 9250759 31663883 + 6 | 33071741 6796745 25397450 24659492 1534922 27995004 + + "Now remember", the voice continues, "that's not even all of the first few numbers; for + example, you're missing the one at 7,1 that would come before 6,2. But, it should be enough to + let your-- oh, it's time for lunch! Bye!" The call disconnects. + + Santa looks nervous. Your puzzle input contains the message on the machine's console. What + code do you give the machine? + + Your puzzle answer was 19980801. + + The first half of this puzzle is complete! It provides one gold star: * + +--- Part Two --- + + The machine springs to life, then falls silent again. It beeps. "Insufficient fuel", the + console reads. "Fifty stars are required before proceeding. One star is available." + + ..."one star is available"? You check the fuel tank; sure enough, a lone star sits at the + bottom, awaiting its friends. Looks like you need to provide 49 yourself. + + You don't have enough stars to start the machine, though. You need x more. + + You can also [Shareon Twitter Google+ Reddit] this puzzle. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/about + . http://adventofcode.com/stats + . http://adventofcode.com/leaderboard + . http://adventofcode.com/settings + . http://adventofcode.com/auth/logout + . http://adventofcode.com/day/1 + . https://en.wikipedia.org/wiki/Copy_protection#Early_video_games + . https://en.wikipedia.org/wiki/Cantor's_diagonal_argument + . https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Let+It+Snow%22+%2D+Day+25+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25&related=ericwastl&hashtags=AdventOfCode + . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25 + . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25&title=I%27ve+completed+Part+One+of+%22Let+It+Snow%22+%2D+Day+25+%2D+Advent+of+Code diff --git a/day01/input b/2016/day01/input similarity index 100% rename from day01/input rename to 2016/day01/input diff --git a/day01/main.go b/2016/day01/main.go similarity index 100% rename from day01/main.go rename to 2016/day01/main.go diff --git a/day01/problem b/2016/day01/problem similarity index 100% rename from day01/problem rename to 2016/day01/problem diff --git a/day02/input b/2016/day02/input similarity index 100% rename from day02/input rename to 2016/day02/input diff --git a/day02/main.go b/2016/day02/main.go similarity index 100% rename from day02/main.go rename to 2016/day02/main.go diff --git a/day02/problem b/2016/day02/problem similarity index 100% rename from day02/problem rename to 2016/day02/problem diff --git a/day03/input b/2016/day03/input similarity index 100% rename from day03/input rename to 2016/day03/input diff --git a/day03/main.go b/2016/day03/main.go similarity index 100% rename from day03/main.go rename to 2016/day03/main.go diff --git a/day03/problem b/2016/day03/problem similarity index 100% rename from day03/problem rename to 2016/day03/problem diff --git a/day04/input b/2016/day04/input similarity index 100% rename from day04/input rename to 2016/day04/input diff --git a/day04/main.go b/2016/day04/main.go similarity index 100% rename from day04/main.go rename to 2016/day04/main.go diff --git a/day04/problem b/2016/day04/problem similarity index 100% rename from day04/problem rename to 2016/day04/problem diff --git a/day05/input b/2016/day05/input similarity index 100% rename from day05/input rename to 2016/day05/input diff --git a/day05/main.go b/2016/day05/main.go similarity index 100% rename from day05/main.go rename to 2016/day05/main.go diff --git a/day05/problem b/2016/day05/problem similarity index 100% rename from day05/problem rename to 2016/day05/problem diff --git a/day06/input b/2016/day06/input similarity index 100% rename from day06/input rename to 2016/day06/input diff --git a/day06/main.go b/2016/day06/main.go similarity index 100% rename from day06/main.go rename to 2016/day06/main.go diff --git a/day06/problem b/2016/day06/problem similarity index 100% rename from day06/problem rename to 2016/day06/problem diff --git a/day07/input b/2016/day07/input similarity index 100% rename from day07/input rename to 2016/day07/input diff --git a/day07/main.go b/2016/day07/main.go similarity index 100% rename from day07/main.go rename to 2016/day07/main.go diff --git a/day07/problem b/2016/day07/problem similarity index 100% rename from day07/problem rename to 2016/day07/problem diff --git a/day08-add/main.go b/2016/day08-add/main.go similarity index 100% rename from day08-add/main.go rename to 2016/day08-add/main.go diff --git a/day08/input b/2016/day08/input similarity index 100% rename from day08/input rename to 2016/day08/input diff --git a/day08/main.go b/2016/day08/main.go similarity index 100% rename from day08/main.go rename to 2016/day08/main.go diff --git a/day08/problem b/2016/day08/problem similarity index 100% rename from day08/problem rename to 2016/day08/problem diff --git a/day09/input b/2016/day09/input similarity index 100% rename from day09/input rename to 2016/day09/input diff --git a/day09/main.go b/2016/day09/main.go similarity index 100% rename from day09/main.go rename to 2016/day09/main.go diff --git a/day09/problem b/2016/day09/problem similarity index 100% rename from day09/problem rename to 2016/day09/problem diff --git a/day10/input b/2016/day10/input similarity index 100% rename from day10/input rename to 2016/day10/input diff --git a/day10/main.go b/2016/day10/main.go similarity index 100% rename from day10/main.go rename to 2016/day10/main.go diff --git a/day10/problem b/2016/day10/problem similarity index 100% rename from day10/problem rename to 2016/day10/problem diff --git a/day11-add/input b/2016/day11-add/input similarity index 100% rename from day11-add/input rename to 2016/day11-add/input diff --git a/day11-add/main.go b/2016/day11-add/main.go similarity index 100% rename from day11-add/main.go rename to 2016/day11-add/main.go diff --git a/day11-add/testinput b/2016/day11-add/testinput similarity index 100% rename from day11-add/testinput rename to 2016/day11-add/testinput diff --git a/day11/input-part1 b/2016/day11/input-part1 similarity index 100% rename from day11/input-part1 rename to 2016/day11/input-part1 diff --git a/day11/input-part2 b/2016/day11/input-part2 similarity index 100% rename from day11/input-part2 rename to 2016/day11/input-part2 diff --git a/day11/main.go b/2016/day11/main.go similarity index 100% rename from day11/main.go rename to 2016/day11/main.go diff --git a/day12/input b/2016/day12/input similarity index 100% rename from day12/input rename to 2016/day12/input diff --git a/day12/main.go b/2016/day12/main.go similarity index 100% rename from day12/main.go rename to 2016/day12/main.go diff --git a/day12/problem b/2016/day12/problem similarity index 100% rename from day12/problem rename to 2016/day12/problem diff --git a/day13/main.go b/2016/day13/main.go similarity index 100% rename from day13/main.go rename to 2016/day13/main.go diff --git a/day13/problem b/2016/day13/problem similarity index 100% rename from day13/problem rename to 2016/day13/problem diff --git a/day14/main.go b/2016/day14/main.go similarity index 100% rename from day14/main.go rename to 2016/day14/main.go diff --git a/day14/problem b/2016/day14/problem similarity index 100% rename from day14/problem rename to 2016/day14/problem diff --git a/day15/input b/2016/day15/input similarity index 100% rename from day15/input rename to 2016/day15/input diff --git a/day15/main.go b/2016/day15/main.go similarity index 100% rename from day15/main.go rename to 2016/day15/main.go diff --git a/day15/problem b/2016/day15/problem similarity index 100% rename from day15/problem rename to 2016/day15/problem diff --git a/day16/input b/2016/day16/input similarity index 100% rename from day16/input rename to 2016/day16/input diff --git a/day16/main.go b/2016/day16/main.go similarity index 100% rename from day16/main.go rename to 2016/day16/main.go diff --git a/day16/problem b/2016/day16/problem similarity index 100% rename from day16/problem rename to 2016/day16/problem diff --git a/day01/day01 b/day01/day01 deleted file mode 100755 index 0c48759..0000000 Binary files a/day01/day01 and /dev/null differ diff --git a/day02/day02 b/day02/day02 deleted file mode 100755 index bb842a9..0000000 Binary files a/day02/day02 and /dev/null differ diff --git a/day03/day03 b/day03/day03 deleted file mode 100755 index f6b3672..0000000 Binary files a/day03/day03 and /dev/null differ diff --git a/day04/day04 b/day04/day04 deleted file mode 100755 index 3d94a2b..0000000 Binary files a/day04/day04 and /dev/null differ diff --git a/day05/day05 b/day05/day05 deleted file mode 100755 index 3df0b7e..0000000 Binary files a/day05/day05 and /dev/null differ diff --git a/day06/day06 b/day06/day06 deleted file mode 100755 index abd7be5..0000000 Binary files a/day06/day06 and /dev/null differ diff --git a/day07/day07 b/day07/day07 deleted file mode 100755 index cbf68da..0000000 Binary files a/day07/day07 and /dev/null differ diff --git a/day08-add/day08-add b/day08-add/day08-add deleted file mode 100755 index a74fcb5..0000000 Binary files a/day08-add/day08-add and /dev/null differ diff --git a/day08/day08 b/day08/day08 deleted file mode 100755 index 16de78d..0000000 Binary files a/day08/day08 and /dev/null differ diff --git a/day09/day09 b/day09/day09 deleted file mode 100755 index 25909f1..0000000 Binary files a/day09/day09 and /dev/null differ diff --git a/day10/day10 b/day10/day10 deleted file mode 100755 index 83f6975..0000000 Binary files a/day10/day10 and /dev/null differ diff --git a/day11-add/day11-add b/day11-add/day11-add deleted file mode 100755 index aeb1375..0000000 Binary files a/day11-add/day11-add and /dev/null differ diff --git a/day11/day11 b/day11/day11 deleted file mode 100755 index 299a130..0000000 Binary files a/day11/day11 and /dev/null differ diff --git a/day12/day12 b/day12/day12 deleted file mode 100755 index 2d0dbcf..0000000 Binary files a/day12/day12 and /dev/null differ diff --git a/day13/day13 b/day13/day13 deleted file mode 100755 index bd44f2e..0000000 Binary files a/day13/day13 and /dev/null differ diff --git a/day14/day14 b/day14/day14 deleted file mode 100755 index 9a49d31..0000000 Binary files a/day14/day14 and /dev/null differ diff --git a/day15/day15 b/day15/day15 deleted file mode 100755 index 6e93965..0000000 Binary files a/day15/day15 and /dev/null differ diff --git a/day16/day16 b/day16/day16 deleted file mode 100755 index 30054a3..0000000 Binary files a/day16/day16 and /dev/null differ