Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
mcdouglasx
on 11/10/2024, 04:04:54 UTC
These accusations are not against the work of JLP, but rather against those who seek the “magic formula” to increase the performance of their implementation,
making you fall into a bias, the faster the better. And yes, the more computing power, the better it works, but this does not mean we can take shortcuts.
The paradox works as long as we do not interfere with its mathematical principles.

The birthday paradox is a mathematical phenomenon that states that in a group of just 23 people, there is a 50.7% probability that at least two of them share the same birthday.
Although at first glance this may seem surprising, it is because there are many possible combinations of pairs within the group.

To understand it better, consider that with 23 people, there are 253 possible pairs (23 × 22 / 2), which significantly increases the probability of matches.
This paradox is an example of how our intuitions can fail in probability problems.

Demonstration:

Suppose we want to find matches among 23 random numbers within 10 million possibilities.

The correct option using the birthday paradox is like this:

Code:
import random
import time

# Parameters
start = 1
end = 10000000
num_people = 23 

birthdays = [random.randint(start, end) for _ in range(num_people)]


print("Generated birthdays:", birthdays)

match_count = 0

for t in range(10):
   
    start_time = time.time()

    i = start
    while i <= end:
        if i in birthdays:
            print(f"Match! Position {i} matches a birthday.")
            match_count += 1
        jump = random.randint(1, 10) 
        i += jump

    end_time = time.time()

    execution_time = end_time - start_time
    print(f"Execution time: {execution_time} seconds")
print(f"Total matches: {match_count}") 


>>Total matches: 52

But wait, I want it faster without more computing power!

So to make the cycle faster, I modify jump = random.randint(1, 10) to jump = random.randint(1, 100)

Code:
import random
import time

# Parameters
start = 1
end = 10000000
num_people = 23 

birthdays = [random.randint(start, end) for _ in range(num_people)]


print("Generated birthdays:", birthdays)

match_count = 0

for t in range(10):
   
    start_time = time.time()

    i = start
    while i <= end:
        if i in birthdays:
            print(f"Match! Position {i} matches a birthday.")
            match_count += 1
        jump = random.randint(1, 100) 
        i += jump

    end_time = time.time()

    execution_time = end_time - start_time
    print(f"Execution time: {execution_time} seconds")
print(f"Total matches: {match_count}") 
   

Total matches: 2

Well, well, I have disregarded the mathematical principles.