This took me far longer than it felt like it should have, but I completed it and it works for numbers -999,999 to 999,999 (as far as I can tell)

The thing I had the most trouble with was figuring...