diff --git a/go.mod b/go.mod index 38097fd..32132ec 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/codemicro/adventOfCode -go 1.17 +go 1.19 require ( github.com/AlecAivazis/survey/v2 v2.3.2 diff --git a/template/README.md b/template/README.md deleted file mode 100644 index 0f2baba..0000000 --- a/template/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# [Day : ](https://adventofcode.com//day/) - diff --git a/template/cookiecutter.json b/template/cookiecutter.json new file mode 100644 index 0000000..3a68447 --- /dev/null +++ b/template/cookiecutter.json @@ -0,0 +1,12 @@ +{ + "_extensions": ["local_extensions.camel_case"], + + "year": 2022, + "dayNumber": 1, + "challengeTitle": null, + + "__formattedTitle": "{{ cookiecutter.challengeTitle | title }}", + "__camelTitle": "{{ cookiecutter.challengeTitle | camel_case }}", + "__formattedDayNumber": "{{ '%02d' | format(cookiecutter.dayNumber|int) }}" +} + diff --git a/template/local_extensions.py b/template/local_extensions.py new file mode 100644 index 0000000..42ad2ad --- /dev/null +++ b/template/local_extensions.py @@ -0,0 +1,14 @@ +from cookiecutter.utils import simple_filter + + +@simple_filter +def camel_case(v): + res = v.split(" ") + for i in range(len(res)): + f = lambda x: x.upper() + if i == 0: + f = lambda x: x.lower() + + res[i] = f(res[i][0]) + res[i][1:] + + return "".join(res) \ No newline at end of file diff --git a/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/README.md b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/README.md new file mode 100644 index 0000000..2ea9750 --- /dev/null +++ b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/README.md @@ -0,0 +1 @@ +# [Day {{ cookiecutter.dayNumber }}: {{ cookiecutter.__formattedTitle }}](https://adventofcode.com/{{ cookiecutter.year }}/day/{{ cookiecutter.dayNumber }}) diff --git a/template/go/challenge.go b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/go/challenge.go similarity index 56% rename from template/go/challenge.go rename to template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/go/challenge.go index 88417ae..105731f 100644 --- a/template/go/challenge.go +++ b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/go/challenge.go @@ -6,10 +6,10 @@ type Challenge struct { aocgo.BaseChallenge } -func (c Challenge) One(instr string) (interface{}, error) { +func (c Challenge) One(instr string) (any, error) { return nil, nil } -func (c Challenge) Two(instr string) (interface{}, error) { +func (c Challenge) Two(instr string) (any, error) { return nil, nil } \ No newline at end of file diff --git a/template/info.json b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/info.json similarity index 100% rename from template/info.json rename to template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/info.json diff --git a/template/nim/challenge.nim b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/nim/challenge.nim similarity index 100% rename from template/nim/challenge.nim rename to template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/nim/challenge.nim diff --git a/template/py/__init__.py b/template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/py/__init__.py similarity index 100% rename from template/py/__init__.py rename to template/{{cookiecutter.__formattedDayNumber}}-{{cookiecutter.__camelTitle}}/py/__init__.py