• + 0 comments

    Putting the required function with different logic: 1. Create a list of reminders for k for each from the given list s. 2. Logic is to identify the sum of reminder's pair to be k 3. Eliminate the reminder with lower count in the created reminder list for each reminder pair. 4. add for the edge condition at i==0 (when only one value can be added such that when added to any other no. the reminder for the sum is not 0 when done with k 5. Add for edge condition when k/2 == i (with the same logic as above) 6. Add the count for each pair of reminders, where the count is the max of the frequency of reminders between the two pairs.

    def nonDivisibleSubset(k, s):
        s_mod = [x % k for x in s]
        print(s_mod)
        s_count = 0
        for i in range(0, ((k // 2)+1)):
            c1 = s_mod.count(i)
            c2 = s_mod.count(k-i)
            if c1 > 0 or c2 > 0 :
                if i == 0:
                    max_cnt_num = 1
                elif k/2 == i:
                    max_cnt_num = 1
                else:
                    max_cnt_num = max(c1,c2)
            else:
                max_cnt_num = 0
            print("MAX_CNT_NUM : ",max_cnt_num)
            s_count += max_cnt_num
            print("COUNT : ",s_count,'\n')
        print(s_count)
        return(int(s_count))