Last active
November 24, 2021 06:11
-
-
Save prio101/45663a548e14d5984f7b5ebf5a38fbf5 to your computer and use it in GitHub Desktop.
Grouping for the Rows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def group(arr): | |
print("given set of the array: ", arr) | |
temp_list = [] | |
group_maker_spice = 3 # base jumper | |
group_maker_spice_special_case_second_row = 2 | |
result_list = [] | |
for item in arr: | |
if item == 0 and len(arr) > group_maker_spice: | |
# insert the first 3 in a group | |
# temp_list.append(0) | |
temp_list = arr[:group_maker_spice] | |
print("first group: ",temp_list) | |
result_list.append(temp_list) | |
temp_list = [] # reset the temp list | |
group_maker_spice = group_maker_spice_special_case_second_row # change to the second row | |
del arr[0:4] #select and delete till the 3rd element | |
if item == 1 and len(arr) > group_maker_spice: | |
temp_list = arr[:group_maker_spice] | |
result_list.append(temp_list) | |
temp_list = [] | |
del arr[0:1] # delete till 2nd element form list | |
# guess this line will throw error | |
# before: result_list.append(list) | |
# after: only add the rest of item | |
result_list.append(arr[item]) | |
print("grouped into three seperate list: ", result_list) | |
# result should be = [[1,2,3], [4,5], [rest....n]] | |
# now run a loop on the view file to get the sets as grouped. | |
# like: while 1 -> 2 do this. | |
# for row 3 just print rest or paginate . | |
def main(): | |
arr = list(range(1, 50)) | |
group(arr) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment