Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-172

Brute Force Time Estimate

Problem

Estimate the average number of seconds to brute force a keyspace when a guesser can try `rate` keys per second. On average half the keyspace is searched:

time = keyspace / (2 * rate)

Hint

The factor of two is the expected position of the key in the search order.

Test cases

case 1
in: [1000000,1000]
expected: 500
case 2
in: [100,1]
expected: 50
case 3
in: [4294967296,1000000]
expected: 2147.483648
case 4
in: [0,10]
expected: 0
Starter codePython
def brute_force_seconds(keyspace, rate):
    # Your code here
    pass

4 test cases · run your code against them in the editor