1.1 solved

This commit is contained in:
2024-12-01 10:56:24 +01:00
parent 680cbe86e7
commit 328b31a1fa
31 changed files with 1392 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
use flake
+2
View File
@@ -23,3 +23,5 @@ cabal.project.local~
.HTF/
.ghc.environment.*
.envrc
.direnv/
+5
View File
@@ -0,0 +1,5 @@
# Revision history for aoc
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.
+211
View File
@@ -0,0 +1,211 @@
cabal-version: 3.4
name: aoc
version: 0.1.0.0
-- synopsis:
-- description:
license: AGPL-3.0-or-later
license-file: LICENSE
author: Nor Führ
maintainer: nor@acorneroftheweb.com
-- copyright:
build-type: Simple
extra-doc-files: CHANGELOG.md
-- extra-source-files:
common warnings
ghc-options: -Wall
executable 1
import: warnings
main-is: 1.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
, split
hs-source-dirs: app
default-language: GHC2021
executable 2
import: warnings
main-is: 2.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 3
import: warnings
main-is: 3.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 4
import: warnings
main-is: 4.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 5
import: warnings
main-is: 5.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 6
import: warnings
main-is: 6.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 7
import: warnings
main-is: 7.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 8
import: warnings
main-is: 8.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 9
import: warnings
main-is: 9.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 10
import: warnings
main-is: 10.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 11
import: warnings
main-is: 11.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 12
import: warnings
main-is: 12.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 13
import: warnings
main-is: 13.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 14
import: warnings
main-is: 14.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 15
import: warnings
main-is: 15.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 16
import: warnings
main-is: 16.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 17
import: warnings
main-is: 17.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 18
import: warnings
main-is: 18.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 19
import: warnings
main-is: 19.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 20
import: warnings
main-is: 20.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 21
import: warnings
main-is: 21.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 22
import: warnings
main-is: 22.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 23
import: warnings
main-is: 23.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
executable 24
import: warnings
main-is: 24.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1
hs-source-dirs: app
default-language: GHC2021
+26
View File
@@ -0,0 +1,26 @@
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant <&>" #-}
module Main where
import Data.Functor
import Data.List.Split
import Data.Char
import Data.Function
import Data.List
parse :: String -> ([Int], [Int])
parse = unzip .
((\case
[a,b] -> (read a, read b)
e -> error $ "Parsing failed on: " ++ show e
) <$>) .
(filter (/= mempty) <$>) .
(splitWhen isSpace <$>) .
lines
solve1 :: ([Int], [Int]) -> Int
solve1 = sum . uncurry (zipWith ((abs .) . (-)) `on` sort)
main :: IO ()
main = readFile "inputs/1" <&> solve1 . parse >>= print
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
Generated
+61
View File
@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1732837521,
"narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+86
View File
@@ -0,0 +1,86 @@
{
description = "aoc goes flakes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
nixConfig.allow-import-from-derivation = true; # cabal2nix uses IFD
outputs = { self, nixpkgs, flake-utils }:
let
ghcVer = "ghc96";
makeHaskellOverlay = overlay: final: prev: {
haskell = prev.haskell // {
packages = prev.haskell.packages // {
${ghcVer} = prev.haskell.packages."${ghcVer}".override (oldArgs: {
overrides =
prev.lib.composeExtensions (oldArgs.overrides or (_: _: { }))
(overlay prev);
});
};
};
};
out = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowBroken = true;
};
in
{
packages = rec {
default = aoc;
aoc = pkgs.haskell.packages.${ghcVer}.aoc;
};
checks = {
inherit (self.packages.${system}) aoc;
};
# for debugging
# inherit pkgs;
devShells.default =
let haskellPackages = pkgs.haskell.packages.${ghcVer};
in
haskellPackages.shellFor {
packages = p: [ self.packages.${system}.aoc ];
withHoogle = true;
buildInputs =
(with pkgs; [
zlib
tailwindcss
just
]) ++
(with haskellPackages; [
haskell-language-server
cabal-install
]);
# Change the prompt to show that you are in a devShell
# shellHook = "export PS1='\\e[1;34mdev > \\e[0m'";
};
};
in
flake-utils.lib.eachDefaultSystem out // {
# this stuff is *not* per-system
overlays = {
default = makeHaskellOverlay (prev: hfinal: hprev:
let hlib = prev.haskell.lib; in
{
aoc = hprev.callCabal2nix "aoc" ./. { };
# here's how to do hacks to the package set
# don't run the test suite
# fast-tags = hlib.dontCheck hprev.fast-tags;
#
# don't check version bounds
# friendly = hlib.doJailbreak hprev.friendly;
});
};
};
}
+1000
View File
File diff suppressed because it is too large Load Diff