Skip to content

Commit 2a24583

Browse files
authored
prepare main branch for 2025 (#843)
* prepare main branch for 2025 * update GitHub Actions stuff
1 parent 39a8870 commit 2a24583

File tree

7 files changed

+116
-18
lines changed

7 files changed

+116
-18
lines changed

.github/workflows/add-daily-article.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
ref: website
2020
submodules: true
2121

22-
- uses: coursier/cache-action@v6
22+
- uses: coursier/cache-action@v7
2323

24-
- uses: VirtusLab/scala-cli-setup@v0.1.18
24+
- uses: VirtusLab/scala-cli-setup@v1.10.1
2525
with:
26-
jvm: "temurin:17"
26+
jvm: "temurin:21"
2727

2828
- name: Generate todays article
2929
run: scala-cli run .github/workflows/scripts/addDay.scala

.github/workflows/schedule-add-daily-article.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
ref: website
2121
submodules: true
2222

23-
- uses: coursier/cache-action@v6
23+
- uses: coursier/cache-action@v7
2424

25-
- uses: VirtusLab/scala-cli-setup@v0.1.18
25+
- uses: VirtusLab/scala-cli-setup@v1.10.1
2626
with:
27-
jvm: "temurin:17"
27+
jvm: "temurin:21"
2828
apps: sbt
2929

3030
- name: Generate todays article

2024/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Scala Advent of Code 2024
2+
3+
Solutions in Scala for the annual [Advent of Code (adventofcode.com)](https://adventofcode.com/) challenge.
4+
5+
_Note: this repo is not affiliated with Advent of Code._
6+
7+
See earlier editions:
8+
9+
- [2021](/2021/README.md)
10+
- [2022](/2022/README.md)
11+
- [2023](/2023/README.md)
12+
13+
## Website
14+
15+
The [Scala Advent of Code](https://scalacenter.github.io/scala-advent-of-code/) website contains:
16+
17+
- some explanation of our solutions to [Advent of Code](https://adventofcode.com/)
18+
- more solutions from the community
19+
20+
## Setup
21+
22+
We use Visual Studio Code with Metals to write Scala code, and scala-cli to compile and run it.
23+
24+
You can follow these [steps](https://scalacenter.github.io/scala-advent-of-code/setup) to set up your environement.
25+
26+
### How to open in Visual Studio Code
27+
28+
After you clone the repository, open a terminal and run:
29+
```
30+
$ cd scala-advent-of-code
31+
$ scala-cli setup-ide 2024
32+
$ mkdir 2024/input
33+
$ code 2024
34+
```
35+
36+
`code 2024` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
37+
the button labelled "Start Metals".
38+
39+
When you navigate to a file, e.g. `2024/src/day01.scala` metals should index the project, and then display code lenses
40+
above each of the main methods `part1` and `part2`, as shown in this image:
41+
![](../img/code-lenses.png)
42+
43+
To run a solution, first copy your input to the folder `2024/input`.
44+
Then click `run` in VS Code which will run the code and display the results of the program. Or `debug`,
45+
which will let you pause on breakpoints, and execute expressions in the debug console.
46+
47+
### How to run a solution with command line
48+
49+
To run a solution, first copy your input to the folder `2024/input`.
50+
51+
In a terminal you can run:
52+
```
53+
$ scala-cli 2024 -M day01.part1
54+
Compiling project (Scala 3.x.y, JVM)
55+
Compiled project (Scala 3.x.y, JVM)
56+
The solution is 64929
57+
```
58+
59+
Or, to run another solution:
60+
```
61+
$ scala-cli 2024 -M <dayX>.<partX>
62+
```
63+
64+
## Contributing
65+
66+
- Please do not commit your puzzle inputs, we can not accept them as they are protected by copyright

2025/project.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//> using scala 3.7.4
2+
//> using option -Wunused:all
3+
//> using test.dep org.scalameta::munit::1.2.1

2025/src/inputs.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package inputs
2+
3+
import scala.util.Using
4+
import scala.io.Source
5+
6+
object Input:
7+
8+
def loadFileSync(path: String): String =
9+
Using.resource(Source.fromFile(path))(_.mkString)

2025/src/locations.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package locations
2+
3+
import scala.quoted.*
4+
5+
object Directory:
6+
7+
/** The absolute path of the parent directory of the file that calls this method
8+
* This is stable no matter which directory runs the program.
9+
*/
10+
inline def currentDir: String = ${ parentDirImpl }
11+
12+
private def parentDirImpl(using Quotes): Expr[String] =
13+
// position of the call to `currentDir` in the source code
14+
val position = quotes.reflect.Position.ofMacroExpansion
15+
// get the path of the file calling this macro
16+
val srcFilePath = position.sourceFile.getJPath.get
17+
// get the parent of the path, which is the directory containing the file
18+
val parentDir = srcFilePath.getParent().toAbsolutePath
19+
Expr(parentDir.toString) // convert the String to Expr[String]

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Scala Advent of Code 2024
1+
# Scala Advent of Code 2025
22

33
Solutions in Scala for the annual [Advent of Code (adventofcode.com)](https://adventofcode.com/) challenge.
44

@@ -9,6 +9,7 @@ See earlier editions:
99
- [2021](/2021/README.md)
1010
- [2022](/2022/README.md)
1111
- [2023](/2023/README.md)
12+
- [2024](/2024/README.md)
1213

1314
## Website
1415

@@ -19,7 +20,7 @@ The [Scala Advent of Code](https://scalacenter.github.io/scala-advent-of-code/)
1920

2021
## Setup
2122

22-
We use Visual Studio Code with Metals to write Scala code, and scala-cli to compile and run it.
23+
We use Visual Studio Code with Metals to write Scala code, and Scala-CLI to compile and run it. (Scala-CLI has been the default `scala` command since Scala 3.5.)
2324

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

@@ -28,39 +29,39 @@ You can follow these [steps](https://scalacenter.github.io/scala-advent-of-code/
2829
After you clone the repository, open a terminal and run:
2930
```
3031
$ cd scala-advent-of-code
31-
$ scala-cli setup-ide 2024
32-
$ mkdir 2024/input
33-
$ code 2024
32+
$ scala setup-ide 2025
33+
$ mkdir 2025/input
34+
$ code 2025
3435
```
3536

36-
`code 2024` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
37+
`code 2025` will open Visual Studio Code and start Metals. If not you may have to go to the Metals pane and click
3738
the button labelled "Start Metals".
3839

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

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

4748
### How to run a solution with command line
4849

49-
To run a solution, first copy your input to the folder `2024/input`.
50+
To run a solution, first copy your input to the folder `2025/input`.
5051

5152
In a terminal you can run:
5253
```
53-
$ scala-cli 2024 -M day01.part1
54+
$ scala 2025 -M day01.part1
5455
Compiling project (Scala 3.x.y, JVM)
5556
Compiled project (Scala 3.x.y, JVM)
5657
The solution is 64929
5758
```
5859

5960
Or, to run another solution:
6061
```
61-
$ scala-cli 2024 -M <dayX>.<partX>
62+
$ scala 2025 -M <dayX>.<partX>
6263
```
6364

6465
## Contributing
6566

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

0 commit comments

Comments
 (0)