您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

4 年前
5 年前
5 年前
2 年前
2 年前
2 年前
5 年前
2 年前
2 年前
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}