Skip to content

Commit

Permalink
Removed input from tool since samples should be done through tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Wulff committed Dec 3, 2024
1 parent 315eb40 commit d3cf912
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This repository provides a framework and helper tools to streamline the process
- `internal/processor.go`: Contains the `PluginProcessor` struct and methods for building plugins, calling functions within those plugins, running tests, and getting input data.
- `internal/input.go`: Contains the `Args` struct and functions for processing command-line arguments and determining file paths.
- `runner.go`: The main entry point that ties everything together by processing arguments, building the plugin, getting input, running tests, and calling the solution function.
- It is expected to set up a folder structure following the pattern: `/year/day/partnumber.go`. For example, for the first part of the first day's challenge in 2024, the file should be located at `/2024/day1/part1.go`.
- It is expected to add test files for each day. As a minimal it is adviced to add a test case for each part of a day based on the sample input and output provided by `Advent of Code`.

## Usage

Expand All @@ -21,11 +23,11 @@ This repository provides a framework and helper tools to streamline the process
To run the tool, use the following command:

```sh
go run runner.go -year=2023 -day=1 -part=1 -input=sample
go run runner.go -year=2024 -day=1 -part=1
```

This command will:
- Process the arguments for year 2023, day 1, part 1, and use the sample input.
- Process the arguments for year 2024, day 1, part 1, and use the sample input.
- Build the plugin for the specified challenge.
- Read the sample input file.
- Run tests for the specified challenge.
Expand Down
19 changes: 7 additions & 12 deletions internal/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,22 @@ import (
)

type Args struct {
day string
part string
input string // sample or input
year string
path string // plugin path
day string
part string
year string
path string // plugin path
}

func ProcessArgs() Args {
year := flag.String("year", fmt.Sprint(time.Now().Year()), "Year of the challenge")
day := flag.String("day", "1", "Day of the challenge")
part := flag.String("part", "1", "Part of the challenge")
input := flag.String("input", "sample", "Puzzle input type (input or sample)")
flag.Parse()

args := Args{
day: *day,
part: *part,
input: *input,
year: *year,
day: *day,
part: *part,
year: *year,
}

path, err := args.getPath()
Expand All @@ -38,8 +35,6 @@ func ProcessArgs() Args {

args.path = path

fmt.Println("Using input type:", args.input)

return args
}

Expand Down
2 changes: 1 addition & 1 deletion internal/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (p PluginProcessor) RunTests() {

func (p PluginProcessor) GetInput() (*[]byte, error) {
// Determine the input file path
path := filepath.Join("./", p.Args.year, "day"+p.Args.day, p.Args.input+".txt")
path := filepath.Join("./", p.Args.year, "day"+p.Args.day, "input.txt")

// Read the input file
data, err := os.ReadFile(path)
Expand Down

0 comments on commit d3cf912

Please sign in to comment.