Difficulty for hash (reversed function of "does hash met difficulty/target") What is an algorithm to determine what maximum difficulty already found hash meets?
See https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_calculated.3F_What_is_the_difference_between_bdiff_and_pdiff.3F

For example, block #347444:

0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 
0x000000000000000014a5256523f37dd374dcb1e0840a85ab4d0cea60bad043d8
= 53256935148.82868


For fun, we can calculate the difficulty the smallest block hash ever mined (as of block #347444) could have satisfied.

First lets get the list from my Bitcoin Abe database:

MariaDB [abe]&gt; SELECT hex(block_hash), block_height FROM block ORDER BY block_hash ASC LIMIT 10;
+------------------------------------------------------------------+--------------+
| hex(block_hash)                                                  | block_height |
+------------------------------------------------------------------+--------------+
| 000000000000000000002D414BB8F9175BA6C6563721E1BA2C1373C2BD94F29F |       334261 |
| 000000000000000000005A5E143087632FBF0EEA743AD99646D9FC67D40F7441 |       336175 |
| 000000000000000000006836C4009AB00485CD1DE4D5958CA7839184D0B80067 |       331908 |
| 000000000000000000007E1166D92ACF81D4E2D95934FCDEC1276B09A7DB9390 |       326055 |
| 000000000000000000007EEF13EE1F2FCF1B469BD862FCC93B48EC49548ECF6D |       343775 |
| 000000000000000000008AC86BA28085BE84AF2EBD6FC6935A004E57FB60C083 |       340483 |
| 00000000000000000000B7DE9E5C19E52BE073156924B7CF235EFB27AE8A202A |       313338 |
| 00000000000000000000EC03E3183BACC8B18437180F63F6A563267A186225BC |       331987 |
| 0000000000000000000119ADB3DA72742B1EBA98F9DC26F73858E91652B42287 |       334151 |
| 0000000000000000000119F88871F8A3C3B7BE053C98B31E9C4676DF30243CFE |       333904 |
+------------------------------------------------------------------+--------------+
10 rows in set (0.06 sec)


Then we pass that to Python (I ran a modified version of the query above to print a format Python understands):

&gt;&gt;&gt; # 334261
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000002D414BB8F9175BA6C6563721E1BA2C1373C2BD94F29F
1592230611213387.2
&gt;&gt;&gt; # 336175
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000005A5E143087632FBF0EEA743AD99646D9FC67D40F7441
797371821285215.2
&gt;&gt;&gt; # 331908
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000006836C4009AB00485CD1DE4D5958CA7839184D0B80067
691428638477639.5
&gt;&gt;&gt; # 326055
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000007E1166D92ACF81D4E2D95934FCDEC1276B09A7DB9390
571568585825999.9
&gt;&gt;&gt; # 343775
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000007EEF13EE1F2FCF1B469BD862FCC93B48EC49548ECF6D
567669438511087.9
&gt;&gt;&gt; # 340483
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000008AC86BA28085BE84AF2EBD6FC6935A004E57FB60C083
519203003284590.0
&gt;&gt;&gt; # 313338
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x00000000000000000000B7DE9E5C19E52BE073156924B7CF235EFB27AE8A202A
391889105139868.25
&gt;&gt;&gt; # 331987
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x00000000000000000000EC03E3183BACC8B18437180F63F6A563267A186225BC
305304486446787.75
&gt;&gt;&gt; # 334151
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x0000000000000000000119ADB3DA72742B1EBA98F9DC26F73858E91652B42287
255811103719832.1
&gt;&gt;&gt; # 333904
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x0000000000000000000119F88871F8A3C3B7BE053C98B31E9C4676DF30243CFE
255545915930877.94


Therefore the highest difficulty target ever attained as of block #347444 is 1,592,230,611,213,387.2 for block #334261

NB: Use Python 3 to get decimals, Python 2.x truncates the fractional digits.