Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

makefile 659B

4 år sedan
5 år sedan
5 år sedan
2 år sedan
2 år sedan
2 år sedan
5 år sedan
2 år sedan
2 år sedan
12345678910111213141516171819
  1. include .env
  2. export
  3. .SILENT:
  4. PYTHONPATH := .
  5. CODE := $(shell find . -path "./y????/p??.py" -type f | xargs ls -rt | tail -n 1)
  6. DATA := $(shell echo ${CODE} | sed s/.py/.dat/)
  7. YEAR := $(shell echo ${CODE} | sed 's/[^0-9]/ /g' | cut -d' ' -f4)
  8. DAY := $(shell echo ${CODE} | sed 's/[^0-9]/ /g' | cut -d' ' -f6)
  9. URL := https://adventofcode.com/${YEAR}/day/`echo ${DAY} | bc`/input
  10. main:
  11. # avoid spam in the lead up to the event
  12. test ${YEAR}${DAY} -le `date +%Y%d`
  13. # only poll if data isn't yet stored locally
  14. test -f ${DATA} || curl -s -b "session=${SESSION}" ${URL} > ${DATA}
  15. # have fun! (access data through `open(0)`)
  16. cat $(DATA) | python3 -u ${CODE}