pass 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):
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 [] '''
def mix(s1, s2): # 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)):
for i in range(times): if isinstance(array[array.index(0)], bool): pos.append(array.index(0) + bool_times) bool_times += 1 else: array.append(0) array.remove(0) for i in pos: array.insert(i, False) else: pass return array if __name__ == "__main__": Test.describe("Basic tests") Test.assert_equals(move_zeros([1, 2, 0, 1, 0, 1, 0, 3, 0, 1]), [1, 2, 1, 1, 3, 1, 0, 0, 0, 0]) Test.assert_equals( move_zeros( [9, 0.0, 0, 9, 1, 2, 0, 1, 0, 1, 0.0, 3, 0, 1, 9, 0, 0, 0, 0, 9]), [9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) Test.assert_equals( move_zeros([ "a", 0, 0, "b", "c", "d", 0, 1, 0, 1, 0, 3, 0, 1, 9, 0, 0, 0, 0, 9 ]), ["a", "b", "c", "d", 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) Test.assert_equals( move_zeros([ "a", 0, 0, "b", None, "c", "d", 0, 1, False, 0, 1, 0, 3, [], 0, 1, 9, 0, 0, {}, 0, 0, 9
right_rest = right - int(pow(2, right_log2)) + 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