-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added `.gitattributes` file * Ran `git add --renormalize .` * Committed the changes
- Loading branch information
Showing
23 changed files
with
849 additions
and
848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
""" | ||
Tests for Advent of Code Day 1. | ||
https://adventofcode.com/2018/day/1 | ||
""" | ||
|
||
from os import path | ||
from .day01 import calculate_frequency, calculate_frequency_two_match | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert calculate_frequency(['+1', '-2', '+3', '+1']) == 3 | ||
assert calculate_frequency(['+1', '+1', '+1']) == 3 | ||
assert calculate_frequency(['+1', '+1', '-2']) == 0 | ||
assert calculate_frequency(['-1', '-2', '-3']) == -6 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_frequency(file_content) == 477 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert calculate_frequency_two_match(['+1', '-2', '+3', '+1']) == 2 | ||
assert calculate_frequency_two_match(['+1', '-1']) == 0 | ||
assert calculate_frequency_two_match(['+3', '+3', '+4', '-2', '-4']) == 10 | ||
assert calculate_frequency_two_match(['-6', '+3', '+8', '+5', '-6']) == 5 | ||
assert calculate_frequency_two_match(['+7', '+7', '-2', '-7', '-4']) == 14 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_frequency_two_match(file_content) == 390 | ||
""" | ||
Tests for Advent of Code Day 1. | ||
https://adventofcode.com/2018/day/1 | ||
""" | ||
|
||
from os import path | ||
from .day01 import calculate_frequency, calculate_frequency_two_match | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert calculate_frequency(['+1', '-2', '+3', '+1']) == 3 | ||
assert calculate_frequency(['+1', '+1', '+1']) == 3 | ||
assert calculate_frequency(['+1', '+1', '-2']) == 0 | ||
assert calculate_frequency(['-1', '-2', '-3']) == -6 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_frequency(file_content) == 477 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert calculate_frequency_two_match(['+1', '-2', '+3', '+1']) == 2 | ||
assert calculate_frequency_two_match(['+1', '-1']) == 0 | ||
assert calculate_frequency_two_match(['+3', '+3', '+4', '-2', '-4']) == 10 | ||
assert calculate_frequency_two_match(['-6', '+3', '+8', '+5', '-6']) == 5 | ||
assert calculate_frequency_two_match(['+7', '+7', '-2', '-7', '-4']) == 14 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_frequency_two_match(file_content) == 390 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
""" | ||
Tests for Advent of Code Day 2. | ||
https://adventofcode.com/2018/day/2 | ||
""" | ||
|
||
from os import path | ||
from .day02 import calculate_checksum, find_correct_id | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert calculate_checksum([ | ||
'abcdef', | ||
'bababc', | ||
'abbcde', | ||
'abcccd', | ||
'aabcdd', | ||
'abcdee', | ||
'ababab', | ||
]) == 12 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_checksum(file_content) == 9633 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert find_correct_id([ | ||
'abcde', | ||
'fghij', | ||
'klmno', | ||
'pqrst', | ||
'fguij', | ||
'axcye', | ||
'wvxyz', | ||
]) == 'fgij' | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert find_correct_id(file_content) == 'lujnogabetpmsydyfcovzixaw' | ||
""" | ||
Tests for Advent of Code Day 2. | ||
https://adventofcode.com/2018/day/2 | ||
""" | ||
|
||
from os import path | ||
from .day02 import calculate_checksum, find_correct_id | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert calculate_checksum([ | ||
'abcdef', | ||
'bababc', | ||
'abbcde', | ||
'abcccd', | ||
'aabcdd', | ||
'abcdee', | ||
'ababab', | ||
]) == 12 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert calculate_checksum(file_content) == 9633 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert find_correct_id([ | ||
'abcde', | ||
'fghij', | ||
'klmno', | ||
'pqrst', | ||
'fguij', | ||
'axcye', | ||
'wvxyz', | ||
]) == 'fgij' | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert find_correct_id(file_content) == 'lujnogabetpmsydyfcovzixaw' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
""" | ||
Tests for Advent of Code Day 3. | ||
https://adventofcode.com/2018/day/3 | ||
""" | ||
|
||
from os import path | ||
from .day03 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
_TEST_DATA = [ | ||
'#1 @ 1,3: 4x4', | ||
'#2 @ 3,1: 4x4', | ||
'#3 @ 5,5: 2x2', | ||
] | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1(_TEST_DATA) == 4 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part1(file_content) == 108961 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2(_TEST_DATA) == 3 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part2(file_content) == 681 | ||
""" | ||
Tests for Advent of Code Day 3. | ||
https://adventofcode.com/2018/day/3 | ||
""" | ||
|
||
from os import path | ||
from .day03 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
_TEST_DATA = [ | ||
'#1 @ 1,3: 4x4', | ||
'#2 @ 3,1: 4x4', | ||
'#3 @ 5,5: 2x2', | ||
] | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1(_TEST_DATA) == 4 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part1(file_content) == 108961 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2(_TEST_DATA) == 3 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part2(file_content) == 681 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
""" | ||
Tests for Advent of Code Day 4. | ||
https://adventofcode.com/2018/day/4 | ||
""" | ||
|
||
from os import path | ||
from .day04 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
_TEST_DATA = [ | ||
'[1518-11-01 00:05] falls asleep', | ||
'[1518-11-03 00:29] wakes up', | ||
'[1518-11-04 00:36] falls asleep', | ||
'[1518-11-01 00:00] Guard #10 begins shift', | ||
'[1518-11-05 00:03] Guard #99 begins shift', | ||
'[1518-11-01 23:58] Guard #99 begins shift', | ||
'[1518-11-04 00:02] Guard #99 begins shift', | ||
'[1518-11-01 00:55] wakes up', | ||
'[1518-11-03 00:05] Guard #10 begins shift', | ||
'[1518-11-01 00:30] falls asleep', | ||
'[1518-11-02 00:50] wakes up', | ||
'[1518-11-05 00:55] wakes up', | ||
'[1518-11-01 00:25] wakes up', | ||
'[1518-11-04 00:46] wakes up', | ||
'[1518-11-02 00:40] falls asleep', | ||
'[1518-11-05 00:45] falls asleep', | ||
'[1518-11-03 00:24] falls asleep', | ||
] | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1(_TEST_DATA) == 240 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part1(file_content) == 73646 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2(_TEST_DATA) == 4455 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part2(file_content) == 4727 | ||
""" | ||
Tests for Advent of Code Day 4. | ||
https://adventofcode.com/2018/day/4 | ||
""" | ||
|
||
from os import path | ||
from .day04 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
_TEST_DATA = [ | ||
'[1518-11-01 00:05] falls asleep', | ||
'[1518-11-03 00:29] wakes up', | ||
'[1518-11-04 00:36] falls asleep', | ||
'[1518-11-01 00:00] Guard #10 begins shift', | ||
'[1518-11-05 00:03] Guard #99 begins shift', | ||
'[1518-11-01 23:58] Guard #99 begins shift', | ||
'[1518-11-04 00:02] Guard #99 begins shift', | ||
'[1518-11-01 00:55] wakes up', | ||
'[1518-11-03 00:05] Guard #10 begins shift', | ||
'[1518-11-01 00:30] falls asleep', | ||
'[1518-11-02 00:50] wakes up', | ||
'[1518-11-05 00:55] wakes up', | ||
'[1518-11-01 00:25] wakes up', | ||
'[1518-11-04 00:46] wakes up', | ||
'[1518-11-02 00:40] falls asleep', | ||
'[1518-11-05 00:45] falls asleep', | ||
'[1518-11-03 00:24] falls asleep', | ||
] | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1(_TEST_DATA) == 240 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part1(file_content) == 73646 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2(_TEST_DATA) == 4455 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.readlines() | ||
assert run_part2(file_content) == 4727 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
""" | ||
Tests for Advent of Code Day 5. | ||
https://adventofcode.com/2018/day/5 | ||
""" | ||
|
||
from os import path | ||
from .day05 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1('aA') == 0 | ||
assert run_part1('abBA') == 0 | ||
assert run_part1('abAB') == 4 | ||
assert run_part1('aabAAB') == 6 | ||
assert run_part1('dabAcCaCBAcCcaDA') == 10 | ||
|
||
# Some edge cases to verify the iteration boundaries | ||
assert run_part1('dabAcCaCBAcCcaDAa') == 9 | ||
assert run_part1('DdabAcCaCBAcCcaDAa') == 8 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.read().strip() | ||
assert run_part1(file_content) == 11894 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2('dabAcCaCBAcCcaDA') == 4 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.read().strip() | ||
assert run_part2(file_content) == 5310 | ||
""" | ||
Tests for Advent of Code Day 5. | ||
https://adventofcode.com/2018/day/5 | ||
""" | ||
|
||
from os import path | ||
from .day05 import run_part1, run_part2 | ||
|
||
_CURRENT_FILE_DIR = path.dirname(__file__) | ||
|
||
|
||
def test_part1(): | ||
"""Tests for Part 1.""" | ||
assert run_part1('aA') == 0 | ||
assert run_part1('abBA') == 0 | ||
assert run_part1('abAB') == 4 | ||
assert run_part1('aabAAB') == 6 | ||
assert run_part1('dabAcCaCBAcCcaDA') == 10 | ||
|
||
# Some edge cases to verify the iteration boundaries | ||
assert run_part1('dabAcCaCBAcCcaDAa') == 9 | ||
assert run_part1('DdabAcCaCBAcCcaDAa') == 8 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.read().strip() | ||
assert run_part1(file_content) == 11894 | ||
|
||
|
||
def test_part2(): | ||
"""Tests for Part 2.""" | ||
assert run_part2('dabAcCaCBAcCcaDA') == 4 | ||
|
||
with open(path.join(_CURRENT_FILE_DIR, 'input'), 'r') as input_file: | ||
file_content = input_file.read().strip() | ||
assert run_part2(file_content) == 5310 |
Oops, something went wrong.