1_tanks ======= 1_tanks-1_fill_up ----------------- >>> from tanks import fill_up >>> fill_up(20, [2, 3, 4, 1, 5, 1]) # doctesttag: +TAG=1_tanks-1_fill_up (False, 0) >>> fill_up(10, [1, 2, 1, 5, 10]) # doctesttag: +TAG=1_tanks-1_fill_up (True, 5) >>> fill_up(10, [1, 2, 1, 5, 1]) # doctesttag: +TAG=1_tanks-1_fill_up (True, 5) >>> fill_up(15, [2, 4, 8, 4, 2, 5, 7, 4]) # doctesttag: +TAG=1_tanks-1_fill_up (True, 4) >>> fill_up(15, [2, 4, 8, 1, 2, 5, 7, 4]) # doctesttag: +TAG=1_tanks-1_fill_up (True, 4) >>> fill_up(1, [1, 4, 8, 1, 2, 5, 7, 4]) # doctesttag: +TAG=1_tanks-1_fill_up (True, 1) 1_tanks-2_select_full --------------------- >>> from tanks import select_full >>> tankL = [ ... ['t1', 20, [2, 3, 4, 1, 5, 1]], ... ['t2', 10, [1, 2, 1, 5, 10]], ... ['t3', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> select_full(tankL) # doctesttag: +TAG=1_tanks-2_select_full [('t2', 5), ('t3', 4)] >>> tankL = [ ... ['t1', 20, [2, 3, 4, 1, 5, 1]], ... ['t2', 30, [1, 2, 1, 5, 10]], ... ['t3', 40, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> select_full(tankL) # doctesttag: +TAG=1_tanks-2_select_full [] >>> tankL = [ ... ['t1', 5, [2, 3, 4, 1, 5, 1]], ... ['t2', 18, [1, 2, 1, 5, 10]], ... ['t3', 7, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> select_full(tankL) # doctesttag: +TAG=1_tanks-2_select_full [('t1', 2), ('t2', 5), ('t3', 3)] >>> tankL = [ ... ['t1', 1, [1, 3, 4, 1, 5, 1]], ... ['t2', 20, [1, 2, 1, 5, 10]], ... ['t3', 100, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> select_full(tankL) # doctesttag: +TAG=1_tanks-2_select_full [('t1', 1)] >>> tankL = [] >>> select_full(tankL) # doctesttag: +TAG=1_tanks-2_select_full [] 1_tanks-3_update_full --------------------- >>> from tanks import update_full >>> tankL = [ ... ['t1', 20, [2, 3, 4, 1, 5, 1]], ... ['t2', 10, [1, 2, 1, 5, 10]], ... ['t3', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> update_full(tankL) >>> tankL == [['t1', 20, [2, 3, 4, 1, 5, 1]],['t2', 10, [1, 2, 1, 5, 1]], ['t3', 15, [2, 4, 8, 1]]] # doctesttag: +TAG=1_tanks-3_update_full True >>> tankL = [ ... ['t1', 20, [2, 3, 4, 1, 5, 1]], ... ['t2', 20, [1, 2, 1, 5, 10]], ... ['t3', 100, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> update_full(tankL) >>> tankL == [['t1', 20, [2, 3, 4, 1, 5, 1]],['t2', 20, [1, 2, 1, 5, 10]], ['t3', 100, [2, 4, 8, 4, 2, 5, 7, 4]]] # doctesttag: +TAG=1_tanks-3_update_full True >>> tankL = [ ... ['t1', 2, [2, 3, 4, 1, 5, 1]], ... ['t2', 3, [1, 2, 1, 5, 10]], ... ['t3', 7, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> update_full(tankL) >>> tankL == [['t1', 2, [2]],['t2', 3, [1, 2]], ['t3', 7, [2, 4, 1]]] # doctesttag: +TAG=1_tanks-3_update_full True 2_sorting ========= 2_sorting-1_tank_sort_1 ----------------------- >>> from tank_sorting import tank_sort_1 >>> tanksL = [ ... ['Ca', 20, [2, 3, 4, 1, 5, 1]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ['Sa', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> newtanksL = tank_sort_1(tanksL) >>> newtanksL == [['Sa', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ['Ca', 20, [2, 3, 4, 1, 5, 1]], ['No', 10, [1, 2, 1, 5, 10]]] # doctesttag: +TAG=2_sorting-1_tank_sort_1 True >>> tanksL = [ ... ['No', 10, [1, 2, 1, 5, 10]], ... ['Ca', 20, [2, 3, 4, 1, 5]], ... ['Sa', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> newtanksL = tank_sort_1(tanksL) >>> newtanksL == [['Sa', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ['No', 10, [1, 2, 1, 5, 10]],['Ca', 20, [2, 3, 4, 1, 5]]] # doctesttag: +TAG=2_sorting-1_tank_sort_1 True >>> tanksL = [ ... ['Ca', 20, [2, 3, 4, 1, 5]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ['Sa', 15, [2, 4, 8, 4, 2]], ... ] >>> newtanksL = tank_sort_1(tanksL) >>> newtanksL == tanksL # doctesttag: +TAG=2_sorting-1_tank_sort_1 True 2_sorting-2_tank_sort_2 ----------------------- >>> from tank_sorting import tank_sort_2 >>> tanksL = [ ... ['Ca', 20, [2, 3, 4, 1, 5, 1]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ['SaP', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['N3', 10, [2, 3, 4, 1, 5, 1]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['SaA', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> res = tank_sort_2(tanksL) >>> res == None and tanksL == [ ... ['Ca', 20, [2, 3, 4, 1, 5, 1]], ... ['SaA', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['SaP', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['N3', 10, [2, 3, 4, 1, 5, 1]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ] # doctesttag: +TAG=2_sorting-2_tank_sort_2 True >>> tanksL = [ ... ['SaA', 5, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['N3', 11, [2, 3, 4, 1, 5, 1]], ... ['SaP', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['No', 17, [1, 2, 1, 5, 10]], ... ['Ca', 20, [2, 3, 4, 1, 5, 1]], ... ] >>> res = tank_sort_2(tanksL) >>> res == None and tanksL ==[ ... ['Ca', 20, [2, 3, 4, 1, 5, 1]], ... ['No', 17, [1, 2, 1, 5, 10]], ... ['SaP', 15, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['N3', 11, [2, 3, 4, 1, 5, 1]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['SaA', 5, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] # doctesttag: +TAG=2_sorting-2_tank_sort_2 True >>> tanksL = [ ... ['Ca', 10, [2, 3, 4, 1, 5, 1]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ['SaP', 10, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['N3', 10, [2, 3, 4, 1, 5, 1]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['SaA', 10, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] >>> res = tank_sort_2(tanksL) >>> res == None and tanksL == [ ... ['Ca', 10, [2, 3, 4, 1, 5, 1]], ... ['N2', 10, [1, 2, 1, 5, 10]], ... ['N3', 10, [2, 3, 4, 1, 5, 1]], ... ['No', 10, [1, 2, 1, 5, 10]], ... ['SaA', 10, [2, 4, 8, 4, 2, 5, 7, 4]], ... ['SaP', 10, [2, 4, 8, 4, 2, 5, 7, 4]], ... ] # doctesttag: +TAG=2_sorting-2_tank_sort_2 True >>> tanksL = [] >>> res = tank_sort_2(tanksL) >>> res == None and tanksL == [] # doctesttag: +TAG=2_sorting-2_tank_sort_2 True 3_numindex ========== 3_numindex-1_numindex_for ------------------------- >>> from numindex import numindex_for >>> l = [0, 4, 2, 4, 3, 5, 6, 7, 9] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [0, 2, 5, 6, 7] >>> l = [1, 4, 2, 4, 3, 5, 6, 7, 8] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [2, 5, 6, 7, 8] >>> l = [-1, 0, 1, 2, 3, 4] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [] >>> l = [0] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [0] >>> l = [0, 1, 2, 3, 4] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [0, 1, 2, 3, 4] >>> l = [] >>> numindex_for(l) # doctesttag: +TAG=3_numindex-1_numindex_for [] 3_numindex-2_numindex_cl ------------------------ >>> from numindex import numindex_cl >>> l = [0, 4, 2, 4, 3, 5, 6, 7, 9] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl [0, 2, 5, 6, 7] >>> l = [1, 4, 2, 4, 3, 5, 6, 7, 8] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl [2, 5, 6, 7, 8] >>> l = [-1, 0, 1, 2, 3, 4] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl [] >>> l = [0] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl [0] >>> l = [0, 1, 2, 3, 4] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl [0, 1, 2, 3, 4] >>> l = [] >>> numindex_cl(l) # doctesttag: +TAG=3_numindex-2_numindex_cl []