Skip to content

Commit

Permalink
Add adder images
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed-dash committed Dec 27, 2024
1 parent 65827ed commit 67fa13b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Binary file added docs/assets/images/1-bit-fa
Binary file not shown.
Binary file added docs/assets/images/ripple-adder
Binary file not shown.
20 changes: 18 additions & 2 deletions src/AoC_2024/Dazbo's_Advent_of_Code_2024.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9203,18 +9203,34 @@
" = 55098960190400\n",
"```\n",
"\n",
"I think this is too big to brute force!\n",
"This is too big to brute force!\n",
"\n",
"#### Solution Approach\n",
"\n",
"Instead, we need to understand what the input data is telling us. The input data contains many AND, OR and XOR instructions, where each instruction takes two input values and produces an output value. Many of these outputs are intermediate inputs to subsequent instructions.\n",
"\n",
"It turns out that these instructions are demonstrating a _ripple adder circuit_. A ripple carry adder is a series of 1-bit adders, where each adder:\n",
"\n",
"- Takes two 1 bit inputs (let's call them `x` and `y`) and a carry input (C<sub>in</sub>).\n",
"- Generates a single _sum_ output.\n",
"- Generates a single carry output (C<sub>out</sub>).\n",
"\n",
"A single adder looks like this:\n",
"\n",
"<img src=\"https://aoc.just2good.co.uk/assets/images/1-bit-fa.png\" width=\"420\" alt=\"Full Adder\" />\n",
"\n",
"So we can implement a multi-bit ripple adder like this:\n",
"\n",
"<img src=\"https://aoc.just2good.co.uk/assets/images/ripple-adder.png\" width=\"420\" alt=\"Ripple Adder\" />\n",
"\n",
"Let's turn our input data into single line readable instructions, for each output. We can use this to look for anomalies.\n",
"\n",
"And we can visualise it too.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 79,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit 67fa13b

Please sign in to comment.