Skip to content

Commit

Permalink
Fix line endings (#16)
Browse files Browse the repository at this point in the history
* Added `.gitattributes` file
* Ran `git add --renormalize .`
* Committed the changes
  • Loading branch information
kfarnung authored Dec 6, 2020
1 parent 8f915d9 commit f8280a0
Show file tree
Hide file tree
Showing 23 changed files with 849 additions and 848 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
70 changes: 35 additions & 35 deletions 2018/day01/test_day01.py
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
88 changes: 44 additions & 44 deletions 2018/day02/test_day02.py
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'
68 changes: 34 additions & 34 deletions 2018/day03/test_day03.py
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
94 changes: 47 additions & 47 deletions 2018/day04/test_day04.py
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
72 changes: 36 additions & 36 deletions 2018/day05/test_day05.py
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
Loading

0 comments on commit f8280a0

Please sign in to comment.