Skip to content

Commit

Permalink
Small fix to day 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamatti committed Dec 7, 2023
1 parent c1f9aba commit 9c558af
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/day_5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
},
{
"cell_type": "markdown",
"id": "92df53f7",
"id": "020ef7cc",
"metadata": {},
"source": [
"Oof, this one was tough. I spent an entire Wednesday evening trying to figure this out. I got tipped by a friend to start from the locations and find a matching seed.\n",
Expand All @@ -266,7 +266,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "545a327f",
"id": "07f4e3e4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -283,7 +283,7 @@
},
{
"cell_type": "markdown",
"id": "732a531f",
"id": "5b36d7d3",
"metadata": {},
"source": [
"Then I did a similar thing with `find_seed` which is the inverse of `find_location`. I give it starting location and ranges in reverse order and find a match for each step. If one is not found, keep the value as it is."
Expand All @@ -292,7 +292,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "23d005ce",
"id": "982c6999",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -309,7 +309,7 @@
},
{
"cell_type": "markdown",
"id": "f1d2b570",
"id": "a682d27c",
"metadata": {},
"source": [
"I needed a way to check if any given number exists as a seed. Since expanding all those ranges would take too much space and looping them processor cycles, I only deal with the lower end and the length.\n",
Expand All @@ -320,7 +320,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "b37db800",
"id": "1a8826e8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -337,7 +337,7 @@
},
{
"cell_type": "markdown",
"id": "1cfcd9d1",
"id": "853f1a26",
"metadata": {},
"source": [
"To get the locations, I find the highest value in any given range and create a range from 1 to that value."
Expand All @@ -346,7 +346,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "67a8b470",
"id": "f0ca6878",
"metadata": {
"scrolled": true
},
Expand All @@ -368,7 +368,7 @@
},
{
"cell_type": "markdown",
"id": "262b472a",
"id": "d9c3d4ee",
"metadata": {},
"source": [
"To find the smallest location that maps to a seed, I start from 1 and loop until I find a matching seed and then stop.\n",
Expand All @@ -378,10 +378,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "d27667e5",
"execution_count": 13,
"id": "140acf8c",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found seed=2243422640 at location=2008785\n",
"Solution: 2008785\n"
]
}
],
"source": [
"part_2 = None\n",
"\n",
Expand All @@ -398,12 +407,12 @@
},
{
"cell_type": "markdown",
"id": "bcbefb20",
"id": "8bb777cb",
"metadata": {},
"source": [
"## Two stars!\n",
"\n",
"Finally, managed to wr"
"Finally, managed to wrap this up before I got too much behind. We're now at 8/50 stars."
]
}
],
Expand Down

0 comments on commit 9c558af

Please sign in to comment.