-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-solution
executable file
·79 lines (61 loc) · 1.16 KB
/
new-solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -e
YEAR="$1"
DAY="$2"
NAME="$3"
if [ -z "$YEAR" ] || [ -z "$DAY" ] || [ -z "$NAME" ]; then
echo "$0 <YEAR> <DAY> <NAME>"
exit 1
fi
DIR=$(printf "%04d/%02d-%s" "$YEAR" "$DAY" "$NAME")
if [ -d "$DIR" ]; then
echo "Directory already exists: $DIR"
exit 1
fi
mkdir -p "$DIR"
touch "$DIR/test.txt" "$DIR/input.txt"
PKG=$(sed 's/-//g' <<< "$NAME")
TITLE=$(sed 's/-/ /g' <<< "$NAME")
cat <<EOF > "$DIR/solution.go"
package $PKG
import (
_ "embed"
"github.com/jbaikge/advent-of-code/solutions"
)
//go:embed test.txt
var testData []byte
//go:embed input.txt
var inputData []byte
func init() {
solutions.Register(new(Solution))
}
type Solution struct{}
func (*Solution) Meta() solutions.Meta {
return solutions.Meta{
Name: "$TITLE",
Year: $YEAR,
Problem: $DAY,
Datas: []solutions.Data{
{
Name: "Test",
Input: testData,
Expect1: 0,
Expect2: 0,
},
{
Name: "Input",
Input: inputData,
},
},
}
}
func (s *Solution) Parse(data []byte) (err error) {
return
}
func (s *Solution) Part1() (answer int, err error) {
return
}
func (s *Solution) Part2() (answer int, err error) {
return
}
EOF