This commit is contained in:
Paul-Henri Froidmont 2021-12-02 23:09:52 +01:00
commit 57918f09c3
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
9 changed files with 2117 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.bloop/
.direnv/
.metals/
.vscode/
out/

2
.scalafmt.conf Normal file
View file

@ -0,0 +1,2 @@
version = "3.0.5"
runner.dialect = scala3

2000
aoc/resources/day1Input.txt Normal file

File diff suppressed because it is too large Load diff

24
aoc/src/Day1.scala Normal file
View file

@ -0,0 +1,24 @@
import scala.io.Source
object Day1 extends App:
val mesurements = Source
.fromURL(getClass.getResource("day1Input.txt"))
.mkString
.split('\n')
.map(_.toInt)
.toList
val total = mesurements.zip(mesurements.drop(1)).map(_ < _).count(identity)
println(s"Part 1: $total")
val windows = mesurements
.zip(mesurements.drop(1))
.zip(mesurements.drop(2))
.map { case ((m1, m2), m3) =>
m1 + m2 + m3
}
val windowsTotal = windows.zip(windows.drop(1)).map(_ < _).count(identity)
println(s"Part 2: $windowsTotal")

5
build.sc Normal file
View file

@ -0,0 +1,5 @@
import mill._, scalalib._
object aoc extends ScalaModule {
def scalaVersion = "3.1.0"
}

43
flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1638376152,
"narHash": "sha256-ucgLpVqhFnClH7YRUHBHnmiOd82RZdFR3XJt36ks5fE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "6daa4a5c045d40e6eae60a3b6e427e8700f1c07f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View file

@ -0,0 +1,30 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
millWithJdk11 = pkgs.mill.override { jre = pkgs.jdk11; };
inputs = with pkgs; [
millWithJdk11
];
in
{
devShell = pkgs.mkShell {
buildInputs = inputs;
shellHook = ''
set -a
JAVA_HOME=${pkgs.jdk11}
set +a
'';
};
}
);
}

7
shell.nix Normal file
View file

@ -0,0 +1,7 @@
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
) {
src = ./.;
}).shellNix