Skip to content

Prepare Solutions for 2024 #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions 2023/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Scala Advent of Code 2023

Solutions in Scala for the annual [Advent of Code](https://adventofcode.com/) challenge. _Note: this repo is not affiliated with Advent of Code._

> See earlier editions:
> - [2021](/2021/README.md)
> - [2022](/2022/README.md)

## Website

The [Scala Advent of Code](https://scalacenter.github.io/scala-advent-of-code/) website contains:
- some explanation of our solutions to [Advent of Code (adventofcode.com)](https://adventofcode.com/)
- more solutions from the community

## Setup

We use Visual Studio Code with Metals to write Scala code, and scala-cli to compile and run it.

You can follow these [steps](https://scalacenter.github.io/scala-advent-of-code/setup) to set up your environement.

### How to open in Visual Studio Code

After you clone the repository, open a terminal and run:
```
$ cd scala-advent-of-code
$ scala-cli setup-ide 2023
$ mkdir 2023/input
$ code 2023
```

`code 2023` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
the button labelled "Start Metals".

When you navigate to a file, e.g. `2023/src/day01.scala` metals should index the project, and then display code lenses
above each of the main methods `part1` and `part2`, as shown in this image:
![](img/code-lenses.png)

To run a solution, first copy your input to the folder `2023/input`.
Then click `run` in VS Code which will run the code and display the results of the program. Or `debug`,
which will let you pause on breakpoints, and execute expressions in the debug console.

### How to run a solution with command line

In a terminal you can run:
```
$ scala-cli 2023 -M day01.part1
Compiling project (Scala 3.x.y, JVM)
Compiled project (Scala 3.x.y, JVM)
The solution is 64929
```

Or, to run another solution:
```
$ scala-cli 2023 -M <dayX>.<partX>
```

By default the solution programs run on our input files which are stored in the `2023/input` folder.
To get your solutions you can change the content of those files in the `2023/input` folder.

## Contributing
- Please do not commit your puzzle inputs, we can not accept them as they are protected by copyright
3 changes: 3 additions & 0 deletions 2024/project.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//> using scala 3.5.2
//> using option -Wunused:all
//> using test.dep org.scalameta::munit::1.0.2
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Scala Advent of Code 2023

Solutions in Scala for the annual [Advent of Code](https://adventofcode.com/) challenge. _Note: this repo is not affiliated with Advent of Code._
Solutions in Scala for the annual [Advent of Code (adventofcode.com)](https://adventofcode.com/) challenge.

> See earlier editions:
> - [2021](/2021/README.md)
> - [2022](/2022/README.md)
_Note: this repo is not affiliated with Advent of Code._

See earlier editions:

- [2021](/2021/README.md)
- [2022](/2022/README.md)
- [2023](/2023/README.md)

## Website

The [Scala Advent of Code](https://scalacenter.github.io/scala-advent-of-code/) website contains:
- some explanation of our solutions to [Advent of Code (adventofcode.com)](https://adventofcode.com/)

- some explanation of our solutions to [Advent of Code](https://adventofcode.com/)
- more solutions from the community

## Setup
Expand All @@ -23,39 +28,39 @@ You can follow these [steps](https://scalacenter.github.io/scala-advent-of-code/
After you clone the repository, open a terminal and run:
```
$ cd scala-advent-of-code
$ scala-cli setup-ide 2023
$ mkdir 2023/input
$ code 2023
$ scala-cli setup-ide 2024
$ mkdir 2024/input
$ code 2024
```

`code 2023` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
`code 2024` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
the button labelled "Start Metals".

When you navigate to a file, e.g. `2023/src/day01.scala` metals should index the project, and then display code lenses
When you navigate to a file, e.g. `2024/src/day01.scala` metals should index the project, and then display code lenses
above each of the main methods `part1` and `part2`, as shown in this image:
![](img/code-lenses.png)

To run a solution, first copy your input to the folder `2023/input`.
To run a solution, first copy your input to the folder `2024/input`.
Then click `run` in VS Code which will run the code and display the results of the program. Or `debug`,
which will let you pause on breakpoints, and execute expressions in the debug console.

### How to run a solution with command line

To run a solution, first copy your input to the folder `2024/input`.

In a terminal you can run:
```
$ scala-cli 2023 -M day01.part1
$ scala-cli 2024 -M day01.part1
Compiling project (Scala 3.x.y, JVM)
Compiled project (Scala 3.x.y, JVM)
The solution is 64929
```

Or, to run another solution:
```
$ scala-cli 2023 -M <dayX>.<partX>
$ scala-cli 2024 -M <dayX>.<partX>
```

By default the solution programs run on our input files which are stored in the `2023/input` folder.
To get your solutions you can change the content of those files in the `2023/input` folder.

## Contributing

- Please do not commit your puzzle inputs, we can not accept them as they are protected by copyright