/joyride-aoc-2022

Script VS Code to solve Advent of Code this year

Primary LanguageClojureOtherNOASSERTION

Use VS Code and Joyride for Advent of Code 2022

Joyride is en extension that lets you script VS Code like Emacs users script Emacs. Like with Emacs the scripting language is a LISP, making the programming fully interactive. The language is not ELisp, though. Instead something much nicer: Clojure. Or, something more familiar to some of you: JavaScript.

Using VS Code for Solving Advent of Code, demo @ Agical

^ Demo using this starter template ^

In the demo I use Clojure for solving Day 1. But you can use JavaScript if you like. Take a look at .joyride/scripts/aoc2022_1_js.cljs and .joyride/src/aoc/day-1.jswhich form a scaffold for how to do this.

How to use this project

This is a template repository to make it quick and easy to get started using VS Code and Clojure to solve Advent of Code problems.

What's included

  • A scaffold script for solving the two parts of Day 1:
  • A utility namespace for loading your AOC problem input for any (released) day
  • Instructions to guide you

Prerequisites

What you need to add

Two VS Code extensions:

  • Joyride - The scripting environment, which includes Clojure and an nREPL server
  • Calva - A Clojure IDE, which includes an nREPL client

Don't worry if you don't have a clue what nREPL is, I won't even link to it here. What ”you will have both a server and a client” means for you is that you don't need anything else to program in Clojure.

Make your AOC browser extension avaliable to your scripts

To use the utility for downloading your AOC problems input, you will need to login to your AOC account and make that session available to the Joyride scripts. The utility script assumes a file named .aoc-session in the workspace root. This file should contain only the contents of the session cookie from the browser's session. A way to get at this cookie is:

  1. Open the browser development console when you are logged in at https://adventofcode.com
  2. Open the Networks tab
  3. Reload the page
  4. Click the resource you have reloaded, (1 if it was the Day 1 problem page)
  5. Look for the cookies in the request headers.
  6. Copy the content (right click -> copy)
  7. Paste the contents into the file .aoc-session

Open the Day one problem script

In VS Code that is.

Depending on if you are going to solve the puzzle in Clojure or JavaScript

Then follow the instructions in the files.

Joyride demo and repo with instructions

See this presentation with demo about what Joyride is and can do:

License

All content in this repository is free to use as you see fit. At your own risk.

Happy Joyriding! 🚗💨

Please join the #joyride channel on Clojurians Slack to get help, provide feedback, and share your solutions. You can also reach us in the Discussions section of the Joyride repository.