Solution for 1009 ("K-based numbers").
Fixed issues detected by GCC.
Draft solution to 1012 ("K-based numbers, version 2"), fails at #6.