https://gist.github.com/scythe/5fb962722934c58c60430180beab8...
In the spirit of the blog post, I'll let you guess how it works :p
q = 101 D = {'102': [3, 2], '105': [7, 5], '121': [11], '169': [13], '289': [17], '361': [19], '529': [23], '841': [29], '961': [31], '1369': [37], '1681': [41], '1849': [43], '2209': [47], '2809': [53], '3481': [59], '3721': [61], '4489': [67], '5041': [71], '5329': [73], '6241': [79], '6889': [83], '7921': [89], '9409': [97]}
q = 101 S = 121 r = 11 D = {'102': [3, 2], '105': [7, 5]}
https://gist.github.com/scythe/5fb962722934c58c60430180beab8...
In the spirit of the blog post, I'll let you guess how it works :p