Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Kostelooscoin on February 24, 2023, 02:37:54 PM



Title: How many operation
Post by: Kostelooscoin on February 24, 2023, 02:37:54 PM
liste = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

while x == 97:


how many operation "+" can we have to obtain 97 knowing that only 17 numbers are allowed.

start with 3 + 5 + 15 numbers


Title: Re: How many operation
Post by: ymgve2 on February 24, 2023, 05:51:50 PM
Look up the "Subset Sum" problem


Title: Re: How many operation
Post by: Kostelooscoin on February 24, 2023, 06:31:17 PM
Code:
import random

x = 1

while x > 0:
    liste1 = random.choice('0123456789abcdef')
    liste2 = random.choice('0123456789abcdef')
    liste3 = random.choice('0123456789abcdef')
    liste4 = random.choice('0123456789abcdef')
    liste5 = random.choice('0123456789abcdef')
    liste6 = random.choice('0123456789abcdef')
    liste7 = random.choice('0123456789abcdef')
    liste8 = random.choice('0123456789abcdef')
    liste9 = random.choice('0123456789abcdef')
    liste10 = random.choice('0123456789abcdef')
    liste11 = random.choice('0123456789abcdef')
    liste12 = random.choice('0123456789abcdef')
    liste13 = random.choice('0123456789abcdef')
    liste14 = random.choice('0123456789abcdef')
    liste15 = random.choice('0123456789abcdef')
    liste16 = 3
    liste17 = 5
    liste = 3+5+int(liste1,16)+int(liste2,16)+int(liste3,16)+int(liste4,16)+int(liste5,16)+int(liste6,16)+int(liste7,16)+int(liste8,16)+int(liste9,16)+int(liste10,16)+int(liste11,16)+int(liste12,16)+int(liste13,16)+int(liste14,16)+int(liste15,16)
    if liste == 97:
        print(str(liste16)+str(liste17)+str(liste1)+str(liste2)+str(liste3)+str(liste4)+str(liste5)+str(liste6)+str(liste7)+str(liste8)+str(liste9)+str(liste10)+str(liste11)+str(liste12)+str(liste13)+str(liste14)+str(liste15))

all good