commit
a6d4c09a28
@ -0,0 +1,129 @@ |
|||||||
|
# Byte-compiled / optimized / DLL files |
||||||
|
__pycache__/ |
||||||
|
*.py[cod] |
||||||
|
*$py.class |
||||||
|
|
||||||
|
# C extensions |
||||||
|
*.so |
||||||
|
|
||||||
|
# Distribution / packaging |
||||||
|
.Python |
||||||
|
build/ |
||||||
|
develop-eggs/ |
||||||
|
dist/ |
||||||
|
downloads/ |
||||||
|
eggs/ |
||||||
|
.eggs/ |
||||||
|
lib/ |
||||||
|
lib64/ |
||||||
|
parts/ |
||||||
|
sdist/ |
||||||
|
var/ |
||||||
|
wheels/ |
||||||
|
pip-wheel-metadata/ |
||||||
|
share/python-wheels/ |
||||||
|
*.egg-info/ |
||||||
|
.installed.cfg |
||||||
|
*.egg |
||||||
|
MANIFEST |
||||||
|
|
||||||
|
# PyInstaller |
||||||
|
# Usually these files are written by a python script from a template |
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it. |
||||||
|
*.manifest |
||||||
|
*.spec |
||||||
|
|
||||||
|
# Installer logs |
||||||
|
pip-log.txt |
||||||
|
pip-delete-this-directory.txt |
||||||
|
|
||||||
|
# Unit test / coverage reports |
||||||
|
htmlcov/ |
||||||
|
.tox/ |
||||||
|
.nox/ |
||||||
|
.coverage |
||||||
|
.coverage.* |
||||||
|
.cache |
||||||
|
nosetests.xml |
||||||
|
coverage.xml |
||||||
|
*.cover |
||||||
|
*.py,cover |
||||||
|
.hypothesis/ |
||||||
|
.pytest_cache/ |
||||||
|
|
||||||
|
# Translations |
||||||
|
*.mo |
||||||
|
*.pot |
||||||
|
|
||||||
|
# Django stuff: |
||||||
|
*.log |
||||||
|
local_settings.py |
||||||
|
db.sqlite3 |
||||||
|
db.sqlite3-journal |
||||||
|
|
||||||
|
# Flask stuff: |
||||||
|
instance/ |
||||||
|
.webassets-cache |
||||||
|
|
||||||
|
# Scrapy stuff: |
||||||
|
.scrapy |
||||||
|
|
||||||
|
# Sphinx documentation |
||||||
|
docs/_build/ |
||||||
|
|
||||||
|
# PyBuilder |
||||||
|
target/ |
||||||
|
|
||||||
|
# Jupyter Notebook |
||||||
|
.ipynb_checkpoints |
||||||
|
|
||||||
|
# IPython |
||||||
|
profile_default/ |
||||||
|
ipython_config.py |
||||||
|
|
||||||
|
# pyenv |
||||||
|
.python-version |
||||||
|
|
||||||
|
# pipenv |
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. |
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies |
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not |
||||||
|
# install all needed dependencies. |
||||||
|
#Pipfile.lock |
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow |
||||||
|
__pypackages__/ |
||||||
|
|
||||||
|
# Celery stuff |
||||||
|
celerybeat-schedule |
||||||
|
celerybeat.pid |
||||||
|
|
||||||
|
# SageMath parsed files |
||||||
|
*.sage.py |
||||||
|
|
||||||
|
# Environments |
||||||
|
.env |
||||||
|
.venv |
||||||
|
env/ |
||||||
|
venv/ |
||||||
|
ENV/ |
||||||
|
env.bak/ |
||||||
|
venv.bak/ |
||||||
|
|
||||||
|
# Spyder project settings |
||||||
|
.spyderproject |
||||||
|
.spyproject |
||||||
|
|
||||||
|
# Rope project settings |
||||||
|
.ropeproject |
||||||
|
|
||||||
|
# mkdocs documentation |
||||||
|
/site |
||||||
|
|
||||||
|
# mypy |
||||||
|
.mypy_cache/ |
||||||
|
.dmypy.json |
||||||
|
dmypy.json |
||||||
|
|
||||||
|
# Pyre type checker |
||||||
|
.pyre/ |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
import days |
||||||
|
import unittest |
||||||
|
|
||||||
|
def suite(): |
||||||
|
suite = unittest.TestSuite() |
||||||
|
suite.addTest(days.Day1('test_day1a')) |
||||||
|
suite.addTest(days.Day1('test_day1b')) |
||||||
|
suite.addTest(days.Day2('test_day2a')) |
||||||
|
return suite |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
runner = unittest.TextTestRunner(verbosity=2) |
||||||
|
runner.run(suite()) |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
from .day1 import Day1 |
||||||
|
from .day2 import Day2 |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
import unittest |
||||||
|
import os |
||||||
|
|
||||||
|
class Day1(unittest.TestCase): |
||||||
|
inputfile = os.path.join(os.path.dirname(__file__), "day1_input") |
||||||
|
|
||||||
|
def calc_fuel(self, mass): |
||||||
|
fuel = mass // 3 - 2 |
||||||
|
if(fuel > 0): |
||||||
|
return fuel + self.calc_fuel(fuel) |
||||||
|
else: |
||||||
|
return 0 |
||||||
|
|
||||||
|
def test_day1a(self): |
||||||
|
fuel = 0 |
||||||
|
with open(self.inputfile) as fp: |
||||||
|
value = fp.readline() |
||||||
|
while value: |
||||||
|
fuel += int(value) // 3 - 2 |
||||||
|
value = fp.readline() |
||||||
|
self.assertEqual(fuel, 3402609) |
||||||
|
|
||||||
|
def test_day1b(self): |
||||||
|
with open(self.inputfile) as fp: |
||||||
|
line = fp.readline() |
||||||
|
sumfuel = 0 |
||||||
|
while line: |
||||||
|
sumfuel += self.calc_fuel(int(line)) |
||||||
|
line = fp.readline() |
||||||
|
self.assertEqual(sumfuel, 5101025) |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
unittest.main() |
||||||
@ -0,0 +1,100 @@ |
|||||||
|
109364 |
||||||
|
144584 |
||||||
|
87498 |
||||||
|
130293 |
||||||
|
91960 |
||||||
|
117563 |
||||||
|
91730 |
||||||
|
138879 |
||||||
|
144269 |
||||||
|
89058 |
||||||
|
89982 |
||||||
|
115609 |
||||||
|
114728 |
||||||
|
85422 |
||||||
|
111803 |
||||||
|
148524 |
||||||
|
130035 |
||||||
|
107558 |
||||||
|
138936 |
||||||
|
95622 |
||||||
|
58042 |
||||||
|
50697 |
||||||
|
86848 |
||||||
|
123301 |
||||||
|
123631 |
||||||
|
143125 |
||||||
|
76434 |
||||||
|
78004 |
||||||
|
91115 |
||||||
|
89062 |
||||||
|
58465 |
||||||
|
141127 |
||||||
|
139993 |
||||||
|
80958 |
||||||
|
104184 |
||||||
|
145131 |
||||||
|
87438 |
||||||
|
74385 |
||||||
|
102113 |
||||||
|
97392 |
||||||
|
105986 |
||||||
|
58600 |
||||||
|
147156 |
||||||
|
54377 |
||||||
|
61409 |
||||||
|
73552 |
||||||
|
87138 |
||||||
|
63168 |
||||||
|
149602 |
||||||
|
111776 |
||||||
|
113191 |
||||||
|
80137 |
||||||
|
145985 |
||||||
|
145177 |
||||||
|
73192 |
||||||
|
141631 |
||||||
|
132979 |
||||||
|
52565 |
||||||
|
126574 |
||||||
|
92005 |
||||||
|
134655 |
||||||
|
115894 |
||||||
|
89175 |
||||||
|
127328 |
||||||
|
139873 |
||||||
|
50072 |
||||||
|
78814 |
||||||
|
134750 |
||||||
|
120848 |
||||||
|
132950 |
||||||
|
126523 |
||||||
|
58206 |
||||||
|
70885 |
||||||
|
85482 |
||||||
|
70889 |
||||||
|
100029 |
||||||
|
68447 |
||||||
|
95111 |
||||||
|
79896 |
||||||
|
138650 |
||||||
|
83079 |
||||||
|
83112 |
||||||
|
117762 |
||||||
|
57223 |
||||||
|
138122 |
||||||
|
145193 |
||||||
|
85251 |
||||||
|
103331 |
||||||
|
134501 |
||||||
|
77023 |
||||||
|
148189 |
||||||
|
141341 |
||||||
|
75994 |
||||||
|
67024 |
||||||
|
137767 |
||||||
|
86260 |
||||||
|
58705 |
||||||
|
58771 |
||||||
|
60684 |
||||||
|
79655 |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
import unittest |
||||||
|
|
||||||
|
class Day2(unittest.TestCase): |
||||||
|
def test_day2a(self): |
||||||
|
self.assertTrue(1 == 1) |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
unittest.main() |
||||||
Loading…
Reference in new issue