<pre><code>(target + space - guess) * 100 / space
</code></pre>
<p>So for example, if your numbers had to be less than 200 and you needed to be less than 20 but got 30, your guess is (20+200-30)*100/200 or 95% right.</p>
<p>This makes sense. There were 200 possible results. You needed to be in a range that covered 10% of that space. You missed by 10, which is 5% of the space. So you were 95% right.</p>
<p>In your case, the space is 2^256. The target is the difficulty.</p>
<p>There are, however, several other possible definitions of how far off you are that produce much lower numbers. This is the more &quot;optimistic&quot; one. For example, if you're looking for an 8-foot tall man, is a 6-foot tall man only off by 2 out of 8 or 25%? That's awfully optimistic and suggests 8-foor tall men are much easier to find than they really are.</p>

CC BY-SA 4.0
2021-05-28T17:42:20.050Z
Thank you for your valuable reply @David Schwartz
J A
CC BY-SA 4.0
2021-05-28T16:40:40.080Z
2021-05-28T16:40:40.080Z
David Schwartz
<p>Sorry for being noob. I am in the process of developing Bitcoin Mining in Python, just curious about whether, can we able to receive the percentage of guess in Target Hash Function via API.</p>
<p>For Example:</p>
<p>Target Hash: 3a42c503953909637f78dd8c99b3b85ddde362415585afc11901bdefe8349102
My hash : aa42c503953909637f78dd8c99b3b85ddde362415585afc11901bdefe8349102</p>
<p>80% Guess kinda..</p>
<p>Your help will be appreciated.</p>
<p>Thank you</p>

CC BY-SA 4.0
2021-05-28T11:35:51.900Z
Hi J A, I'm not sure I understand your question fully, but it seems helpful to point out that Bitcoin mining is searching for a partial preimage, but the restriction is that a valid block's hash must be numerically smaller than the target. The actual values do not need to match.
Murch
<mining-pools><bitcoin-core-development><miner-configuration><cpuminer>
Bit Coin Mining
J A
# Bit Coin Mining

(Asked by: username_0 on 2021-05-27)

Sorry for being noob. I am in the process of developing Bitcoin Mining in Python, just curious about whether, can we able to receive the percentage of guess in Target Hash Function via API.

For Example:

Target Hash: 3a42c503953909637f78dd8c99b3b85ddde362415585afc11901bdefe8349102
My hash : aa42c503953909637f78dd8c99b3b85ddde362415585afc11901bdefe8349102

80% Guess kinda..

Your help will be appreciated.

Thank you

**Tags:** mining-pools, bitcoin-core-development, miner-configuration, cpuminer

> **Comments:**
> **username_1**: Hi J A, I'm not sure I understand your question fully, but it seems helpful to point out that Bitcoin mining is searching for a partial preimage, but the restriction is that a valid block's hash must be numerically smaller than the target. The actual values do not need to match.  

---

## 1 answers

### Answer by username_2 on 2021-05-28. Score: 1

```
(target + space - guess) * 100 / space

```

So for example, if your numbers had to be less than 200 and you needed to be less than 20 but got 30, your guess is (20+200-30)\*100/200 or 95% right.

This makes sense. There were 200 possible results. You needed to be in a range that covered 10% of that space. You missed by 10, which is 5% of the space. So you were 95% right.

In your case, the space is 2^256. The target is the difficulty.

There are, however, several other possible definitions of how far off you are that produce much lower numbers. This is the more "optimistic" one. For example, if you're looking for an 8-foot tall man, is a 6-foot tall man only off by 2 out of 8 or 25%? That's awfully optimistic and suggests 8-foor tall men are much easier to find than they really are.

> **Comments:**
> **username_0**: Thank you for your valuable reply @username_2  

---

