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:
parent
781a8c6669
commit
58850f81a6
4 changed files with 1067 additions and 0 deletions
1000
2023/1-1.in
Normal file
1000
2023/1-1.in
Normal file
File diff suppressed because it is too large
Load diff
17
2023/1-1.nix
Normal file
17
2023/1-1.nix
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue