Solutions in Scala for the annual Advent of Code challenge. Note: this repo is not affiliated with Advent of Code.
The Scala Advent of Code website contains:
- some explanation of our solutions to Advent of Code (adventofcode.com)
- more solutions from the community
We use Visual Studio Code with Metals to write Scala code, and scala-cli to compile and run it.
You can follow these steps to set up your environement.
After you clone the repository, open a terminal and run:
$ cd scala-advent-of-code/2021
$ scala-cli setup-ide src
$ mkdir input
$ code .
code .
will open Visual Studio Code and start Metals.
First copy your input to the folder scala-advent-of-code/2021/input
.
Next, in a terminal you can run:
$ cd scala-advent-of-code/2021
$ scala-cli . -M day1.part1
Compiling project (Scala 3.x.y, JVM)
Compiled project (Scala 3.x.y, JVM)
The solution is 1559
The result will likely be different for you, as inputs are different for each user.
Or, to run another solution:
$ scala-cli . -M <dayX>.<partX>
By default the solution programs run on our input files which are stored in the input
folder.
To get your solutions you can change the content of those files in the input
folder.
The solution of day 3 is written for the javascript target.
You can run it locally, if you have Node.js installed, by adding the --js
option:
$ scala-cli . --js -M day3.part1
- Please do not commit your puzzle inputs, we can not accept them as they are protected by copyright