Premiers puzzles
This commit is contained in:
parent
e035736b6c
commit
92ff3757ad
|
@ -3,99 +3,11 @@ __pycache__/
|
|||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# 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/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# dotenv
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
.venv
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
# Advent of Code puzzle inputs
|
||||
input.txt
|
||||
input
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
digits = [int(c) for c in sys.stdin.readline().rstrip()]
|
||||
|
||||
sum = 0
|
||||
for i in range(len(digits)):
|
||||
if digits[i] == digits[(i+1)%len(digits)]:
|
||||
sum = sum + digits[i]
|
||||
|
||||
print(sum)
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
digits = [int(c) for c in sys.stdin.readline().rstrip()]
|
||||
|
||||
sum, half = 0, int(len(digits)/2)
|
||||
for i in range(len(digits)):
|
||||
if digits[i] == digits[(i+half)%len(digits)]:
|
||||
sum = sum + digits[i]
|
||||
|
||||
print(sum)
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
data = [[int(n.rstrip()) for n in l.split('\t')] for l in sys.stdin]
|
||||
|
||||
maxnum, minnum = [max(l) for l in data], [min(l) for l in data]
|
||||
diff = [maxnum[n] - minnum[n] for n in range(len(maxnum))]
|
||||
print(sum(diff))
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from itertools import product
|
||||
|
||||
data = [[int(n.rstrip()) for n in l.split('\t')] for l in sys.stdin]
|
||||
|
||||
result = []
|
||||
for line in [list(product(l, l)) for l in data]:
|
||||
for tup in line:
|
||||
if tup[0] == tup[1]:
|
||||
continue
|
||||
if tup[0] % tup[1] == 0:
|
||||
result.append(tup)
|
||||
break
|
||||
elif tup[1] % tup[0] == 0:
|
||||
result.append((tup[1], tup[0]))
|
||||
break
|
||||
|
||||
print(sum(tup[0] / tup[1] for tup in result))
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
lines = [line.rstrip().lower().split(" ") for line in sys.stdin.readlines()]
|
||||
print(len([1 for line in lines if len(set(line)) == len(line)]))
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
lines = [l.strip().split(" ") for l in sys.stdin.readlines()]
|
||||
|
||||
print(sum([len(l)==len(set("".join(sorted(s)) for s in l)) for l in lines]))
|
||||
|
Loading…
Reference in New Issue