Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
encse committed Dec 13, 2024
1 parent fcd96ae commit d07d1be
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion 2024/Day01/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## --- Day 1: Historian Hysteria ---
The <em>Chief Historian</em> is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check the places they think he was most likely to visit.

Read the [full puzzle](https://adventofcode.com/2024/day/1).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/1) description._

Our warm-up puzzle involves list comparisons. It'll take me a bit of time to get back into C#, as I find it a bit noisy now, but anyway... The first half is simply calculating the pairwise differences between two lists. The second half involves summing the elements of the first list, weighted by their occurrences in the second list.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day02/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fortunately, the first location The Historians want to search isn't a long walk

While the _Red-Nosed Reindeer nuclear fusion/fission plant_ appears to contain no sign of the Chief Historian, the engineers there run up to you as soon as they see you. Apparently, they <em>still</em> talk about the time Rudolph was saved through molecular synthesis from a single electron.

Read the [full puzzle](https://adventofcode.com/2024/day/2).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/2) description._

I created a function to check the validity of a single input line. This is achieved using the usual method of _zipping_ the input with itself to generate a list of consecutive pairs. The next step involves checking the monotonicity condition (either increasing or decreasing) for each pair.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

The shopkeeper turns to you. "Any chance you can see why our computers are having issues again?"

Read the [full puzzle](https://adventofcode.com/2024/day/3).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/3) description._

I took a functional approach today. Regular expressions are ugly beasts, I normally try avoid them. Fortunately, we're not writing production code here. Otherwise... everything is just a fold if you look at it from a distance.
2 changes: 1 addition & 1 deletion 2024/Day04/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Looks like the Chief's not here. Next!" One of The Historians pulls out a device and pushes the only button on it. After a brief flash, you recognize the interior of the __Ceres monitoring station__!
As the search for the Chief continues, a small Elf who lives on the station tugs on your shirt; she'd like to know if you could help her with her <em>word search</em>. She only has to find one word: <code>XMAS</code>.

Read the [full puzzle](https://adventofcode.com/2024/day/4).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/4) description._

I employed my proven tactic of converting the input into a dictionary, using coordinates as keys. This approach makes it straightforward to iterate over the keys and check whether they fall within the bounds of the map.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day05/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The North Pole printing department is busier than ever this close to Christmas,

The Elf must recognize you, because they waste no time explaining that the new <em>sleigh launch safety manual</em> updates won't print correctly. Failure to update the safety manuals would be dire indeed, so you offer your services.

Read the [full puzzle](https://adventofcode.com/2024/day/5).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/5) description._

The constraints in both my input and the provided sample input define a total ordering of the pages, which I leveraged in my solution. (*) I implemented a custom parser that returns the list of updates to be printed and a page comparison function. That's all we need. In `Part1`, we check which updates are in the correct order, while in `Part2`, we handle the remaining updates by applying .NET's built-in `OrderBy` function with our custom comparer.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day06/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The Historians use their fancy __device__ again, this time to whisk you all away

You still have to be careful of time paradoxes, and so it will be important to avoid anyone from 1518 while The Historians search for the Chief. Unfortunately, a single <em>guard</em> is patrolling this part of the lab.

Read the [full puzzle](https://adventofcode.com/2024/day/6).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/6) description._

This has been a straightforward implementation challenge. I wrote a `Walk` function that tracks the guard's movement and returns the visited locations. It also determines whether the guard enters a loop or exits the grid. `Part1` utilizes only the location information, while `Part2` adds blockers along the guard's path and counts the instances where he starts walking in a cycle.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day07/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The Historians take you to a familiar _rope bridge_ over a river in the middle o

When you go to cross the bridge, you notice a group of engineers trying to repair it. (Apparently, it breaks pretty frequently.) You won't be able to cross until it's fixed.

Read the [full puzzle](https://adventofcode.com/2024/day/7).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/7) description._

It's time to pull out the recursion guns. I introduced a checker logic that goes through the numbers in one line of input and tries all possible operators on the accumulated result to reach the target.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day08/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ You find yourselves on the _roof_ of a top-secret Easter Bunny installation.

While The Historians do their thing, you take a look at the familiar <em>huge antenna</em>. Much to your surprise, it seems to have been reconfigured to emit a signal that makes people 0.1% more likely to buy Easter Bunny brand Imitation Mediocre Chocolate as a Christmas gift! Unthinkable!

Read the [full puzzle](https://adventofcode.com/2024/day/8).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/8) description._

Continuing the steps I started yesterday, I extracted a common function (`GetUniquePositions`) that takes a parameter to generate antinode positions, representing the difference between part one and part two.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Another push of the button leaves you in the familiar hallways of some friendly

While The Historians quickly figure out how to pilot these things, you notice an amphipod in the corner struggling with his computer. He's trying to make more contiguous free space by compacting all of the files, but his program isn't working; you offer to help.

Read the [full puzzle](https://adventofcode.com/2024/day/9).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/9) description._

I'm taking a break from using LINQ today and turning my attention to the low-level world of linked lists instead. I discovered a way to express both paths using a single `CompactFs` function with a `fragmentsEnabled` parameter. `CompactFs` operates with two pointers, `i` and `j`, which define the scan range we’re working on. `i` starts at the beginning of the disk, while `j` starts at the end and moves backward. When `i` points to a free space and `j` points to a used space, we call `RelocateBlock`, which moves `j` (or parts of `j`, depending on whether fragmentation is enabled) to a free space found after `i`.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day10/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ You all arrive at a _Lava Production Facility_ on a floating island in the sky.

The reindeer is holding a book titled "Lava Island Hiking Guide". However, when you open the book, you discover that most of it seems to have been scorched by lava! As you're about to ask how you can help, the reindeer brings you a blank [topographic map](https://en.wikipedia.org/wiki/Topographic_map) of the surrounding area (your puzzle input) and looks up at you excitedly.

Read the [full puzzle](https://adventofcode.com/2024/day/10).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/10) description._

Today's problem is surprisingly straightforward compared to yesterday's pointer juggling. We finally get to use our favorite queue data structure to implement a flood fill. I saw this coming...

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The ancient civilization on _Pluto_ was known for its ability to manipulate spac

At first glance, they seem like normal stones: they're arranged in a perfectly <em>straight line</em>, and each stone has a <em>number</em> engraved on it.

Read the [full puzzle](https://adventofcode.com/2024/day/11).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/11) description._

Today is all about dynamic programming and cached calculations. Our goal is to determine the number of stones based on specific rules derived from the numbers engraved on them. Without careful optimization, this process can quickly spiral out of control.

Expand Down
2 changes: 1 addition & 1 deletion 2024/Day12/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Why not search for the Chief Historian near the _gardener_ and his _massive farm

You're about to settle near a complex arrangement of garden plots when some Elves ask if you can lend a hand. They'd like to set up fences around each region of garden plots, but they can't figure out how much fence they need to order or how much it will cost. They hand you a map (your puzzle input) of the garden plots.

Read the [full puzzle](https://adventofcode.com/2024/day/12).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/12) description._

One can sense that the difficulty has ramped up today with a more complex problem involving area and perimeter calculations.

Expand Down
6 changes: 3 additions & 3 deletions 2024/Day13/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## --- Day 13: Claw Contraption ---
Next up: the _lobby_ of a resort on a tropical island. The Historians take a moment to admire the hexagonal floor tiles before spreading out.

Next up: the [lobby](/2020/day/24) of a resort on a tropical island. The Historians take a moment to admire the hexagonal floor tiles before spreading out.
Fortunately, it looks like the resort has a new [arcade](https://en.wikipedia.org/wiki/Amusement_arcade)! Maybe you can win some prizes from the [claw machines](https://en.wikipedia.org/wiki/Claw_machine)?

Read the [full puzzle](https://adventofcode.com/2024/day/13).
_Visit the website for the full story and [puzzle](https://adventofcode.com/2024/day/13) description._

We got a math problem today. The movements triggered by buttons A, B and the target position P form a linear equation that we can solve for the two unknowns: the number of button presses. Using math terms, if _i_ and _j_ marks the number of button presses, we are to solve `A * i + B * j = P`. This is simple enough to do using [Cramer's rule](https://en.wikipedia.org/wiki/Cramer%27s_rule), especially with two dimensional vectors. In this case the determinats can be computed with a simple cross product. We should not forget about the special cases: A and B can be parallel (didn't occur in my input), and the solution needs to be non negative integer for _i_ and _j_.
2 changes: 1 addition & 1 deletion Lib/Model/Problem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Problem Parse(int year, int day, string url, IDocument document, s
static string ParseMdIntro(IDocument document, int paragraphs, string url) {
var article = ParseMd(document).Split("\n\n").ToList();
article = article.Take(Math.Min(paragraphs, article.Count)).ToList();
article.Add($"Read the [full puzzle]({url}).\n");
article.Add($"_Visit the website for the full story and [full puzzle]({url}) description._\n");
return string.Join("\n\n", article);
}

Expand Down
4 changes: 2 additions & 2 deletions docs/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function generateYearPicker(year, day, yearToDays) {

return `<nav class="dropdown">
<input type="checkbox" id="dropdown-toggle" class="dropdown-toggle">
<label id="dropdown-label" for="dropdown-toggle"><span class="current">${year}<span></label>
<span class="current"><label id="dropdown-label" for="dropdown-toggle">${year}</label></span>
<div class="dropdown-content">${options}</div>
</nav>
`;
Expand Down Expand Up @@ -134,7 +134,7 @@ const lastDay = Math.max(...yearToDays[lastYear]);
copyDirectory('docs/static', 'build');

const filledRedirectTemplate = fillTemplate(redirectTemplate, {
'default-page-url': `https://aoc.csokavar.hu/${lastYear}/${lastDay}/`,
'default-page': `/${lastYear}/${lastDay}/`,
});

fs.writeFileSync(path.join('build', 'index.html'), filledRedirectTemplate);
Expand Down
2 changes: 1 addition & 1 deletion docs/redirect_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
if (url.search.match(/^\?(\d{4})\/\d{1,2}/)) {
window.location = url.search.substring(1);
} else {
window.location = '{{default-page-url}}';
window.location = '{{default-page}}';
}
</script>
17 changes: 9 additions & 8 deletions docs/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@

#dropdown-label {
text-align: center;
}
#dropdown-label span {
padding: 0;
margin: 0 0.25em;
margin: 1em;
}

.dropdown-toggle {
Expand All @@ -136,10 +133,13 @@

.dropdown-content {
flex-direction: column;
padding: 1em;
gap: 0.5em;
padding: 1em;

}

.dropdown-content a {
margin: 0.5em 1em;
}

#dropdown-toggle:checked ~ .dropdown-content {
display: flex;
}
Expand Down Expand Up @@ -228,7 +228,8 @@


#top-nav span,
#top-nav .dropdown {
#top-nav .dropdown
#top-nav .dropdown-content {
padding: 0.25em;
}

Expand Down

0 comments on commit d07d1be

Please sign in to comment.