Skip to content

Instantly share code, notes, and snippets.

@luoyetx
Created September 5, 2016 07:18
Show Gist options
  • Save luoyetx/fb9557dc1eb371ba1bf8ade5d562516f to your computer and use it in GitHub Desktop.
Save luoyetx/fb9557dc1eb371ba1bf8ade5d562516f to your computer and use it in GitHub Desktop.
solve an email address
import math
ps = [
0.0000008110673199286165000000000000000000,
0.0000162907226016170940000000000000000000,
0.0024177576053697383000000000000000000000,
0.0000000054649286143693143000000000000000,
0.0003272079103201879800000000000000000000,
0.0000000148552161462659780000000000000000,
0.0065721465642952148000000000000000000000,
0.0000000148552161462659780000000000000000,
0.0000000000000000000000254604802054643040,
0.0000059930219269618815000000000000000000,
0.0065721465642952148000000000000000000000,
0.9753930336921978700000000000000000000000,
0.0008894433167514238800000000000000000000,
0.0000000054649286143693143000000000000000,
0.0000162907226016170940000000000000000000,
0.0003272079103201879800000000000000000000,
0.0000000000000000000000000000003877625978,
0.0000000403806641082262080000000000000000,
0.0065721465642952148000000000000000000000,
0.0008894433167514238800000000000000000000,
]
if __name__ == '__main__':
# minimum ascii character is '.'
ascii_min = ord('.')
p_min = min(ps)
p_max = max(ps)
# solver softmax parameter `max` and `sum`
sf_sum = 1. / p_max
sf_max = int(round(ascii_min - math.log(p_min * sf_sum)))
# convert back
email = ''
for p in ps:
ascii = int(round(math.log(p * sf_sum) + sf_max))
ch = chr(ascii)
email += ch
print email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment