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
n = 10 | |
c = [2, 3, 5, 6] | |
ways = [[0 if i < min(c) else - 1 for i in range(n + 1)] for j in c] | |
def num_ways(n, c): | |
row = len(c) - 1 | |
# base case | |
if n < min(c): return 0 | |
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 find_k(arr_i, l ,r, ends): | |
# ends here is a sorted array. | |
# binary search | |
while r - l > 1: | |
m = (l+r)//2 | |
if arr_i <= ends[m]: r = m | |
else: l = m | |
return r | |
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
// | |
// filter.swift | |
// fltr | |
// | |
// Created by Avinash on 18/06/19. | |
// Copyright © 2019 eightyfive. All rights reserved. | |
// | |
import Metal | |
import MetalKit |
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
class Constant(): | |
def __init__(self, value): | |
self.value = value | |
self.gradient = None | |
def evaluate(self): | |
return self.value | |
def derivative(self, wrt_variable): |
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
class Node: | |
""" | |
Vertex / Node in a bipartite graph | |
Attributes | |
---------- | |
id : int | |
Unique identifier within a set | |
set: int |