def coin_change(S, m, n): table = [[0 for x in range(m)] for x in range(n+1)] for i in range(m): table[0][i] = 1 for i in range(1, n+1): for j in range(m): x = table[i - S[j]][j] if i-S[j] >= 0 else 0 y = table[i][j-1] if j >= 1 else 0 table[i][j] = x + y return table[n][m-1] ================ import re def text_match_wordz_middle(text): patterns = '\Bz\B' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!') text_match_wordz_middle('ciao') ============== def max_occurrences(list1): max_val = 0 result = list1[0] for i in list1: occu = list1.count(i) if occu > max_val: max_val = occu result = i return result ================ def sort_matrix(M): result = sorted(M, key=sum) return result ================= def get_ludic(n): ludics = [] for i in range(1, n + 1): ludics.append(i) return ludics print(get_ludic(a*a)) ================= def adjac(ele, sub = []): if not ele: yield sub else: yield from [ idx for j in range(ele[0] - 1, ele[0] + 2) for idx in adjac(ele[1:], sub + [j]) ] def get_coordinates(test_tup): res = list(adjac(test_tup)) return (res) =================== import heapq def heap_sort(iterable): h = [] for value in iterable: heapq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))] ====================== def get_ludic(n): ludics = [] for i in range(1, n + 1): ludics.append(i) index = 1 while(index != len(ludics)): first_ludic = ludics[index] remove_index = index + first_ludic while(remove_index < len(ludics)): ludics.remove(ludics[remove_index]) remove_index = remove_index + first_ludic - 1 index += 1 return ludics print(get_ludic(a*a)) ============================ from collections import defaultdict def get_unique(test_list): res = defaultdict(list) for sub in test_list: res[sub[1]].append(sub[0]) res = dict(res) res_dict = dict() for key in res: res_dict[key] = len(list(set(res[key]))) return (str(res_dict))