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
# Uses python3 | |
import sys | |
# returns the ratio of value to weight | |
def getValueRatio(item): | |
return (item[0]/item[1]) | |
def checkInput(n, min, max): | |
if n<min or n>max: | |
return True |
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
# Uses python3 | |
import sys | |
import random | |
def binary_search(a, x): | |
left, right = 0, len(a) | |
def linear_search(a, x): | |
for i in range(len(a)): | |
if a[i] == x: |
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
# Uses python3 | |
import sys | |
def knapSackNoRep(capacity, bars): | |
amount = len(bars) | |
value=[[0 for row in range(0, amount+1)] for col in range(0, capacity+1)] | |
for i in range(1, amount+1): | |
wi = bars[i-1] |
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
# python3 | |
import sys | |
class Bracket: | |
def __init__(self, bracket_type, position): | |
self.bracket_type = bracket_type | |
self.position = position | |
def Match(self, c): |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |