defdivide_and_conquer(nums,length):iflength==1:return[[num]fornuminnums]smaller_combinations=divide_and_conquer(nums,length-1)all_combinations=[]forcombinationinsmaller_combinations:fornuminnums:ifnumnotincombination:all_combinations.append(combination+[num])returnall_combinationsdefgenerate_combinations(nums,length):iflength==0:return[[]]ifnotnums:return[]current_num=nums[0]remaining_nums=nums[1:]with_current=[[current_num]+combinationforcombinationingenerate_combinations(remaining_nums,length-1)]without_current=generate_combinations(remaining_nums,length)returnwith_current+without_current# Define the range of numbers and the length of combinationsnumbers=[1,2,3,4,5]combination_length=3# Generate all possible combinationscombinations=generate_combinations(numbers,combination_length)# Print each combinationforcombinationincombinations:print(combination)