Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

39 Zeilen
1.1KB

  1. include .env
  2. export
  3. .SILENT:
  4. FILE := $(shell find . -path "./y????/p??.*" -type f | xargs ls -rt | tail -n 1)
  5. PYTHON := docker compose run --rm advent python
  6. YEAR := $(shell echo ${FILE} | sed -E 's/.+y([0-9]+).+/\1/')
  7. DAY := $(shell echo ${FILE} | sed -E 's/.+p([0-9]+).+/\1/' | bc)
  8. URL := https://adventofcode.com/${YEAR}/day/${DAY}
  9. BASE := $(shell echo ${FILE} | sed -E 's/\....?$$//')
  10. CODE := $(BASE).py
  11. DATA := $(BASE).dat
  12. TEST := $(BASE).dtt
  13. main: ${TEST}
  14. echo 'test:'
  15. cat ${TEST} | ${PYTHON} -u ${CODE}
  16. clean: ${DATA}
  17. echo 'real:'
  18. cat ${DATA} | ${PYTHON} -u ${CODE}
  19. save:
  20. git add .
  21. test `git log -1 --format=%s` == `cat VERSION` \
  22. && git commit --amend --reuse-message=head \
  23. || git commit -m `cat VERSION`
  24. ${DATA} ${TEST}:
  25. # avoid spam in the lead up to the event
  26. TZ=America/New_York test ${DAY} -le `date +%d` || test ${YEAR} -lt `date +%Y`
  27. # only poll if data isn't yet stored locally
  28. test -f ${DATA} || curl -s -b "session=${SESSION}" ${URL}/input > ${DATA}
  29. # try to get test data
  30. test -f ${TEST} || curl -s ${URL} | tr '\n' '@' | perl -pe 's|.+?<pre><code>(.+?)</code></pre>.+|\1|' | tr '@' '\n' > ${TEST}