As many others here, I believe I have the right answer, but it isn’t accepted. If someone would look over my code via PM I’d be happy (I don’t want to put any spoilers here).
My program is in Python, and the relevant part is really just one line.
One quick question though: does “total number of visible ASCII characters” refer to the number of non-space characters in the message to be encrypted, or the number of printable characters in the ASCII table (e.g. 95)? I’ve tried both, but without luck.