Spoilers Ahead! The full solution to the problem is available here.
Problem - Part 01
Given a list of adapters marked with different joltages (akin to voltages in the real-world), find a chain of all of your adapters to connect them to your device which supports any adapter with a range -3 <= joltage <= 3, and connect the device with the adapter to a charger outlet (marked as 0J). Once you find the chain, count the number of joltages with 1 / 3 as difference
Although the problem sounds too wordy, the main idea behind it is to change uniquely identify a list of adapters, that have + or - 3 less than or greater than a specified target joltage. Once we have that we can calculate the adapters with the right difference in joltage.
Let’s create a way to count and hold the joltage differences.
Alright, now that we have a way to store the differences let’s write a function to get count of all the adapter differences from the target device joltage.
From the problem it is also mentioned that the target device voltage is +3 of the max joltage adapter.
To get the answer for Part 01 of our puzzle, we need to call these functions and find the count joltages with difference of 1 and 3 respectively.