1. 48.Weight problems 2

    w=[2,5,11]
    n=9
    L=len(w)
    s=[-1 for i in range(n+1)]
    s[0]=0
    print s
    for i in range(L):
        for j in range(1,n+1):
            if j-w[i]>=0 and s[j-w[i]]!=-1: # n>=each weight, their difference ...
    read more
  2. 47.Yang hui triangle

    n=6
    l0 = [1]
    l1 = [1,1]
    print " ".join([str(x) for x in l0])
    print " ".join([str(x) for x in l1])
    for i in range(2, n):
        lnew = [1]
        for j in range(1, len(l1)):
            lnew.append(l1[j-1]+l1[j])
        lnew.append(1)
        l1 = lnew ...
    read more
  3. 46.Take stones game

    # (1, 2) (3, 5) (4, 7) (6, 10) (8, 13) (9, 15) (11, 18) (12, 20) (14, 23) (16, 26) (17, 28) (19, 31)...
    # a/b = (sqrt(5) - 1)/2 = 0.618
    
    a=8
    b=13
    if a > b:
        a, b = b, a
    k = b - a
    c = k * 1.6180339887498949 ...
    read more
  4. 45.Weight problems

    w=[1,3]
    n=[2,1]
    W = [0]
    L = [0]
    for i,v in enumerate(n):
        for j in range(v+1):
            L.append(j * w[i])
        W = list(set([x+y for x in W for y in L]))
        print L
        print W
        L=[0]
    print len(list(set ...
    read more
  5. 41.Py

    n=2992
    def py(n,m):
        total = 0
        while n>0:
            total+=n%m
            n=n/m
        return total
    print py(n,10)==py(n,16)==py(n,12) and "Yes" or "No"
    
    read more

« Page 16 / 21 »

blogroll

social