This is a slightly closer solution, but I'm still going to miss when k > 2.
I finally ran the system tests and realized I had two fail cases "808" and "10". Now I know why some submitters converted their ints to strings first.