Skip to content

Instantly share code, notes, and snippets.

View thomastay's full-sized avatar

Thomas Tay thomastay

View GitHub Profile
@thomastay
thomastay / interview_recursive_warmups.cpp
Last active August 8, 2019 22:15
Recursive problems for interviews
/* Warmup Questions */
/* Warmup 1: array Length recursive
Write a function that takes in the start of the array and the end,
and returns the length of the array
See test for examples
*/
int arrLenRec(int* start, int* end)
{
#!/bin/bash
#set -x
DATE=`date +%Y-%m-%d`
echo "Log from $DATE" > out.log
ENTRIES=8 #TODO: Please change me!
#Arrays are separated by spaces!
ARRAY=(
https://www.youtube.com/playlist?list=PLqKSWM3wXgnrMlice2vo63ZqzqG0LOghw
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <random>
using namespace std;
#!/usr/bin/python3
from itertools import permutations
#This program checks that there are four and only four numbers in their natural position
def checkPmt(pmt, numInPosition = 4):
#pmt is a tuple of length n
currInPosition = 0;
for i,k in enumerate(pmt):
if (i+1 == k): currInPosition += 1;
@thomastay
thomastay / cycleParser.py
Created January 16, 2018 05:28
cycleParser for Math 296
#!python3
from itertools import product
def parseCycle(cycle, n):
permutation = [0 for i in range(n)]
cycle_start = 0
prev = 0
for i in range(len(cycle)):
cur = cycle[i]
if cur == cycle_start: