There are two solutions that probably work equally well: one is to convert the SNAFU number to decimal, do the math, and convert back to SNAFU. The other is to do the math directly in SNAFU. I went with the second approach because it looks more mathy.
A SNAFU number can be represented as:
i=0∑ndi⋅5i
Where di∈{−2,−1,0,1,2} and i starts from the rightmost digit. I store it as a list of digits from the least significant one.
How the digit and carry are derived just requires casework. Our goal is to make the digit between -2 and 2, while si can be at least -5 (if both digits are -2 and the carry is -1) and at most 5 (if both digits are 2 and the carry is 1).
If −5≤si≤−3, then we need to add 5 to it, which generates a carry of -1. −3≤si+2≤−1, so ⌊(si+2)/5⌋=−1, and (si+2)mod5=si+2+5.
If −2≤si≤2, then we don't need to add anything, and the carry is 0. 0≤si+2≤4, so ⌊(si+2)/5⌋=0, and (si+2)mod5=si+2.
If 3≤si≤5, then we need to subtract 5 from it, which generates a carry of 1. 5≤si+2≤7, so ⌊(si+2)/5⌋=1, and (si+2)mod5=si+2−5.
As for the implementation, I implemented it as a three-way addition of number 1, number 2, and the carry. It stops when both numbers are empty and the carry is 0.