Better template for python
This commit is contained in:
parent
d4dc30e699
commit
b721bc6a71
|
@ -1,12 +1,37 @@
|
|||
|
||||
|
||||
from aocd import submit
|
||||
|
||||
with open("input.txt") as f:
|
||||
# https://adventofcode.com/YEAR/day/DAY
|
||||
#
|
||||
## USAGE ##
|
||||
# Run with 'input.txt' and submit with aocd:
|
||||
# python3 python.py
|
||||
# Run with 'test.txt' and don't submit:
|
||||
# python3 python.py test.txt
|
||||
# Run with stdin and don't submit:
|
||||
# cat myinput | python3 python.py -
|
||||
# aoc d -y YEAR -d DAY -oi /dev/stdout | python3 python.py -
|
||||
# aocd DAY YEAR | python3 python.py -
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
submit( , "a", DAY, YEAR)
|
||||
import sys
|
||||
inputfn = sys.argv[1] if len(sys.argv) > 1 else "input.txt"
|
||||
|
||||
submit( , "b", DAY, YEAR)
|
||||
from aocd import submit
|
||||
|
||||
with open(0 if inputfn == '-' else inputfn) as f:
|
||||
lines = f.read().splitlines()
|
||||
|
||||
|
||||
|
||||
# part 1
|
||||
print()
|
||||
if inputfn == "input.txt":
|
||||
submit(, "a", day=DAY, year=YEAR)
|
||||
|
||||
|
||||
|
||||
# part 2
|
||||
print()
|
||||
if inputfn == "input.txt":
|
||||
submit(, "b", day=DAY, year=YEAR)
|
||||
|
|
Loading…
Reference in New Issue