示例#1
0
    return temp[n]


	# your code



if __name__ == "__main__":

    t0 = time.perf_counter()

    def testing(actual, expected):
        Test.assert_equals(actual, expected)

    Test.describe("dbl_linear")
    Test.it("Basic tests")	
    testing(dbl_linear(10), 22)
    testing(dbl_linear(20), 57)
    testing(dbl_linear(30), 91)
    testing(dbl_linear(50), 175)



    print(time.perf_counter() - t0)




'''
def last_digit(lst):
    if not lst:
示例#2
0
    


    return visible_allcover(clues)
    #return ( (1, 2, 3, 4), (2, 3, 4, 1), (3, 4, 1, 2), (4, 1, 2, 3) )


if __name__ == "__main__":

    t0 = time.perf_counter()

    clues = ((2, 2, 1, 3, 2, 2, 3, 1, 1, 2, 2, 3, 3, 2, 1, 3),
             (0, 0, 1, 2, 0, 2, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0))

    outcomes = (((1, 3, 4, 2), (4, 2, 1, 3), (3, 4, 2, 1), (2, 1, 3, 4)),
                ((2, 1, 4, 3), (3, 4, 1, 2), (4, 2, 3, 1), (1, 3, 2, 4)))

    test.describe("4 by 4 skyscrapers")
    test.it("should pass all the tests provided")
    print(clues_compare(solve_puzzle(outcomes[0]),clues[0]))
    # test.assert_equals(solve_puzzle(clues[0]), outcomes[0])
    # test.assert_equals(solve_puzzle(clues[1]), outcomes[1])

    print(time.perf_counter() - t0)
'''
def snail(array):
    return list(array[0]) + snail(zip(*array[1:])[::-1]) if array else []

'''
示例#3
0
    # your code
    t1 = (count_str_alpha(s1))
    print(t1)
    t2 = (count_str_alpha(s2))
    print(t2)
    t2.update(t1)
    print(t2)
    return 0
    #count_alpha(count_str_alpha(s1))


if __name__ == "__main__":

    t0 = time.perf_counter()
    Test.describe("Mix")
    Test.it("Basic Tests")
    Test.assert_equals(mix("Are they here", "yes, they are here"),
                       "2:eeeee/2:yy/=:hh/=:rr")
    # Test.assert_equals(mix("looping is fun but dangerous", "less dangerous than coding"), "1:ooo/1:uuu/2:sss/=:nnn/1:ii/2:aa/2:dd/2:ee/=:gg")
    # Test.assert_equals(mix(" In many languages", " there's a pair of functions"), "1:aaa/1:nnn/1:gg/2:ee/2:ff/2:ii/2:oo/2:rr/2:ss/2:tt")
    # Test.assert_equals(mix("Lords of the Fallen", "gamekult"), "1:ee/1:ll/1:oo")
    # Test.assert_equals(mix("codewars", "codewars"), "")
    # Test.assert_equals(mix("A generation must confront the looming ", "codewarrs"), "1:nnnnn/1:ooooo/1:tttt/1:eee/1:gg/1:ii/1:mm/=:rr")

    print(time.perf_counter() - t0)
'''
def pick_peaks(arr):
    pos = []
    prob_peak = False
    for i in range(1, len(arr)):
        if arr[i] > arr[i-1]:
        if right_rest:
            out_temp += right_rest
            left_t =  1
            right_t = right & (int(pow(2, right_log2)) - 1)
            out_temp += countOnes(left_t, right_t)
        else:
            pass
    return out_temp


if __name__ == "__main__":

    t0 = time.perf_counter()

    test.describe("Sample Tests")
    test.it('Easy')
    test.assert_equals(countOnes(5, 7), 7)
    test.assert_equals(countOnes(4, 7), 8)
    test.assert_equals(countOnes(12, 29), 51)
    test.assert_equals(countOnes(12, 2900000000000000), 51)   #test time

    print(time.perf_counter() - t0)



'''
import math

def count(n):
    if n is 0: return 0
    x = int(math.log(n, 2))
            temp = lst[i] % 4
            if temp == 3:
                remainder_temp_t = remainder[temp][refer_temp % 2]
            else:
                remainder_temp_t = remainder[temp][min(num_temp - 1, 1)]
            num_temp = num_temp_t
            refer_temp = refer_temp_t
            remainder_temp = remainder_temp_t
    return refer_temp


if __name__ == "__main__":

    t0 = time.perf_counter()

    test.it('Basic tests')
    test_data = [([], 1), ([0, 0], 1), ([0, 0, 0], 0), ([1, 2], 1),
                 ([3, 4, 5], 1), ([4, 3, 6], 4), ([7, 6, 21], 1),
                 ([12, 30, 21], 6), ([2, 2, 2, 0], 4),
                 ([937640, 767456, 981242], 0), ([123232, 694022, 140249], 6),
                 ([499942, 898102, 846073], 6)]
    for test_input, test_output in test_data:
        test.assert_equals(last_digit(test_input), test_output)

    print(time.perf_counter() - t0)
'''
def last_digit(lst):
    if not lst:
        return 1
    else:
        out = 1
def last_digit(n1, n2):
    out_temp=n1%10
    if n2==0:
        out_temp=1
    else :
        refer_temp=refer[out_temp]
        out_temp=refer_temp[(n2%len(refer_temp))-1]
    return out_temp


if __name__ == "__main__":

    t0 = time.perf_counter()

    Test.it("Example tests")
    Test.assert_equals(last_digit(4, 1), 4)
    Test.assert_equals(last_digit(4, 2), 6)
    Test.assert_equals(last_digit(9, 7), 9)
    Test.assert_equals(last_digit(10, 10 ** 10), 0)
    Test.assert_equals(last_digit(2 ** 200, 2 ** 300), 6)
    Test.assert_equals(last_digit(3715290469715693021198967285016729344580685479654510946723, 68819615221552997273737174557165657483427362207517952651), 7)

    Test.it("x ** 0")
    for nmbr in range(1, 9):
        a = nmbr ** nmbr
        Test.it("Testing %d and %d" % (a, 0))
        Test.assert_equals(last_digit(a, 0), 1, "x ** 0 must return 1")