Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

39 linhas
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. 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. save:
  13. git add .
  14. test `git log -1 --format=%s` == `cat VERSION` \
  15. && git commit --amend --reuse-message=head \
  16. || git commit -m `cat VERSION`
  17. git log -1
  18. main: ${TEST}
  19. echo 'test':
  20. cat ${TEST} | docker compose run --rm advent python -u ${CODE}
  21. clean: ${DATA}
  22. echo 'real:'
  23. cat ${DATA} | docker compose run --rm advent python -u ${CODE}
  24. ${DATA} ${TEST}:
  25. # avoid spam in the lead up to the event
  26. 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}