CJam, 147 bytes, printable ------------------------------- "T>&T@BJjD2It!7Eb=V;p@?^*50(n6@PC-\JN.K)iLWgtOtDTtPc.;T )b*8-We<Bkt_)SZo:RW6<F`#B8)5#5CH:H2 "1/{ciK-}%99b2b26,65f+:c_m*]z{~SS+?S+}%26/N* Pretty straightforward approach [Try it online here][1] [1]: http://cjam.aditsu.net/