1
Fork 0
mirror of https://github.com/RGBCube/AdventOfCode synced 2025-07-27 03:57:44 +00:00

Add day 1 part 1

This commit is contained in:
RGBCube 2023-12-01 18:00:08 +03:00
parent 781a8c6669
commit 58850f81a6
No known key found for this signature in database
4 changed files with 1067 additions and 0 deletions

1000
2023/1-1.in Normal file

File diff suppressed because it is too large Load diff

17
2023/1-1.nix Normal file
View file

@ -0,0 +1,17 @@
{ lib, input }:
with lib; with builtins; let
lines = splitString "\n" input;
linesChars = map (splitString "") lines;
linesOnlyNumbers = map (filter (char: (match "[0-9]" char) != null)) linesChars;
firstAndLastConcatted = list: (head list) + (last list);
linesNumbers = map firstAndLastConcatted linesOnlyNumbers;
sumOfLinesNumbers = foldl' add 0 (map fromJSON linesNumbers);
result = sumOfLinesNumbers;
in result