This repository has been archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(default.md): correct typo in author field from "autor" to "author…
…" for consistency feat(default.md): add support for draft field to mark content as draft feat(day1-aoc-daniel.md): add new project page for AoC - Day 1 with Elixir & OCaml code fix(list.html): improve styling of list items with flexbox layout and add author name to each post
- Loading branch information
1 parent
18f99da
commit 0a7c007
Showing
3 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
author: "Daniel Boll" | ||
title: "AoC - Day 1" | ||
date: 2023-12-01T09:44:14-03:00 | ||
description: "Using Elixir & OCaml" | ||
draft: false | ||
--- | ||
|
||
Uh, hi? | ||
|
||
```elixir | ||
defmodule Day1 do | ||
@spec part_one(String.t()) :: integer() | ||
def part_one(file) do | ||
load_file(file) | ||
|> Enum.map(fn calibration -> | ||
numbers = | ||
calibration | ||
|> String.split("") | ||
|> Enum.filter(&Regex.match?(~r/\d/, &1)) | ||
|
||
numbers | ||
|> Kernel.hd() | ||
|> Kernel.<>(List.last(numbers)) | ||
|> String.to_integer() | ||
end) | ||
|> Enum.sum() | ||
end | ||
|
||
@spec load_file(String.t()) :: [String.t()] | ||
def load_file(file) do | ||
File.read!(file) | ||
|> String.trim_trailing() | ||
|> String.split("\n") | ||
end | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters