Skip to content

joshpierce/advent-of-code-22

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code 2022

This year I decided I'd learn the Kotlin language while working on solutions for Advent of Code. 😅 Hopefully I can get past the day 10 hump without life getting in the way this year, but should be a fun learning experience nonetheless.

The solutions that are provided here are probably not the "best way" of doing things. I'm looking forward to learning along the way and figuring out different ways to accomplish these problems with Kotlin 🙌.

If you'd like to follow along, I'll provide the steps below that I took to get this all up and running. This should allow you to go from Fresh Windows install to running the code in this repository.

Getting Started With Kotlin in VS Code on Windows 11 🏃

Install the Java JDK

First we'll start by installing the JDK.

  1. Click the link above to go to the JDK download page.
    Note: Currently I've installed the Java 19 JDK.
  2. Choose the Windows tab and download the x64 installer.
  3. Run the installer and let it take all the default options.

Install the Kotlin Command-Line Compiler

Next we'll install the Kotlin Command-Line Compiler.

  1. Download the kotlin-compiler-[version].zip file from the link above.
  2. Extract the zip file into a folder at c:\Program Files\kotlinc.

Add The JDK and Kotlin Compiler to Environment Variables

  1. Open your start menu and type in environment variables, then click Edit the system environment variables.
  2. Click the button at the bottom labeled Environment Variables.
  3. Under the section labeled User variables for ... click the New Button.
  4. Enter a Variable Name of JAVA_HOME and a Variable Value of c:\Program Files\Java\jdk-19 (note: this assumes you installed version 19).
  5. Click OK
  6. Under the section labeled System Variables, find the variable named Path, select it, and click Edit....
  7. Click the New button and add C:\Program Files\kotlinc\bin. (Make sure that this is the path that contains the kotlinc app).
  8. Click the New button again and add C:\Program Files\Java\jdk-19\bin. (This again assumes the Java 19 version)
  9. Click OK.
  10. Click OK again.

Download and install Git

You'll need to have git installed locally for all this to work. You can download it and install it here.

Restart Windows

This is just the easiest way to make sure your path is updated, it's probably enough to restart any open terminals that you have, but this guarantees that it works well.

Open Windows Terminal

Next, we'll make sure that your java and kotlin compiler are both installed properly. Open the start menu and type Terminal and open windows terminal. Run the following two commands and you should see similar output to the below:

javac -version
# javac 19.0.1

kotlinc -version
# info: kotlinc-jvm 1.7.21 (JRE 19.0.1+10-21)

As long as you see the above, you should be in good shape.

While we're here, let's run the following code to pull this repository and get it ready to run:

mkdir gitroot

cd gitroot

git clone https://github.com/joshpierce/advent-of-code-22

Now you should have the repository locally to tinker with.

Download and install VS Code

Next, we'll download and install Visual Studio (VS) Code. This should be pretty self explanatory.

Open the repository in Visual Studio Code

Open up a new Windows Terminal window like above, and run the following commands:

cd gitroot

cd advent-of-code-22

code .

This is shorthand to open VS Code with the scope of whatever folder you're in, it's handy.

Install a Few VS Code Extensions

  • Code Runner - This we'll use to run our Kotlin code in VS Code.
  • Kotlin Language - This will help us with syntax highlighting and code completion.
  • Extension Pack for Java - I don't know if this is needed, but might be nice for Java development. Remember, I'm new here too. 🙃
  • vscode-icons - Because they're awesome. ❤️

Run the Code

Inside VS Code, you should now be able to navigate to the src/DayXX.kt files, and right click on them and choose Run Code. Any output from the files should be placed in the output window at the bottom of VS Code. You will need to add the associated day's input file from Advent of Code alongside the DayXX.kt files. For instance, you can copy and paste your input file from AOC into Day01.txt right next to Day01.kt to run the Day 1 solution.

If I Forgot Anything

I'm sorry 😞 Send me a message and I'd be happy to help if possible.

Links 🔗

If you're stuck with Kotlin-specific questions or anything related to this template, check out the following resources:

About

Repository for Advent of Code 22

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages