You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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