def add_binary(): """TODO: Docstring for add_binary. :returns: TODO """ A = random_int_list(0, 1, 10) B = random_int_list(0, 1, 10) C = [] print("A = ", A) print("B = ", B) A.append(0) B.append(0) for i in range(len(A)): key = A[i] + B[i] if key == 0 or key == 1: C.append(key) elif key == 2: C.append(0) A[i + 1] += 1 else: C.append(1) A[i + 1] += 1 print("C = ", C)
# -*- coding:utf-8 -*- __author__ = 'ShawDa' from random_list import random_int_list def select_sort(arr): for i in range(len(arr)): tmp = min(arr[i:]) tmp_index = arr[i:].index(tmp) arr[i], arr[i + tmp_index] = arr[i + tmp_index], arr[i] return arr if __name__ == '__main__': data = random_int_list(1, 100, 10) print(data) print(select_sort(data))
#!/usr/bin/env python # -*- coding: utf-8 -*- import time import Sort from random_list import random_int_list start = time.perf_counter() sort = random_int_list(0, 100, 100) print(sort) #sorted = Sort.INSERTION_SORT_NE(sort) sorted = Sort.SELECT_SORT(sort) #sorted = Sort.MERGE_SORT(sort, 0, len(sort) - 1) print(sorted) elapsed = (time.perf_counter() - start) print("Time used: ", elapsed)