Skip to content

Instantly share code, notes, and snippets.

View teldridge11's full-sized avatar
💭
🦅

Tom Eldridge teldridge11

💭
🦅
View GitHub Profile
void dyHeapRemoveMin(DynamicArray* heap, compareFunction compare)
{
// FIXME: implement
int last = dySize(heap)-1;
assert (last != 0); /* make sure we have at least one element */
/* Copy the last element to the first position */
dyPut(heap, dyGet(heap, last), 0);
dyRemoveAt(heap, last); /* Remove last element.*/
adjustHeap(heap, last, 0, compare);/* Rebuild heap */
}
void buildHeap(DynamicArray* heap, compareFunction compare)
{
// FIXME: implement
for(int i=dySize(heap)/2-1;i>=0;i--) {
adjustHeap(heap, dySize(heap)-1, i, compare);
}
}
void hashMapPut(HashMap* map, const char* key, int value) {
// FIXME: implement
float load = hashMapTableLoad(map);
if(load >= MAX_TABLE_LOAD) {
resizeTable(map, hashMapCapacity(map));
}
int i = HASH_FUNCTION(key) % map->capacity;
HashLink *cur = map->table[i];
while(cur) {
if(strcmp(cur->key, key) == 0) {
def majority(array, tiebreaker=None):
n = len(array)
if n == 0:
return tiebreaker
pairs = []
if n % 2 == 1:
tiebreaker = array[-1]
for i in range(0, n-1, 2):
if array[i] == array[i+1]:
pairs.append(array[i])
import matplotlib.pyplot as plt
import time
import numpy as np
import sympy
from sympy import S, symbols
import random
from math import floor
def randomArray(totalNumbers,min,max):
array = []
from pulp import *
# Creates a list of the Ingredients
Ingredients = ['TOMATO', 'LETTUCE', 'SPINACH', 'CARROT', 'SUNFLOWER', 'TOFU', 'CHICKPEAS', 'OIL']
kcal = {'TOMATO': 21,
'LETTUCE': 16,
'SPINACH': 40,
'CARROT': 41,
'SUNFLOWER': 585,
Problem 2
Part A:
i.
MINIMIZE e
to = 21e + 0.85p + 0.33f + 4.64c + 9s + 1cs
le = 16e + 1.62p + 0.2f + 2.37c + 28s + 0.75cs
sp = 40e + 2.86p + 0.39f + 3.63c + 65s + 0.50cs
<?php echo(“Hello world!”); ?>
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[034m\]\$(parse_git_branch)\[\033[0m\] $ "
[alias]
co = checkout
br = branch
st = status
c = commit
import matplotlib
import seaborn as sns
import pandas as pd
from scipy.stats import zscore
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import DBSCAN
from matplotlib import cm
from datetime import datetime
from dateutil import parser
import json