Skip to content

Instantly share code, notes, and snippets.

View anirudhpillai's full-sized avatar

Anirudh Pillai anirudhpillai

View GitHub Profile
from next_num import RandomGen
from collections import Counter
def main():
random_nums = [-1, 0, 1, 2, 3]
probabilities = [0.01, 0.3, 0.58, 0.1, 0.01]
rg = RandomGen(random_nums, probabilities)
from next_num import RandomGen
import math
import unittest
# I would have used pytest for writing tests
# as it provides me decorators like parametrize
# but for the sake of the assignment I'm just sticking
# with the standard library :)
from functools import lru_cache
from typing import List
import math
import random
class RandomGen:
"""
Class for a random generator that selects a number from a given list.
select p.product_id
from Products as p
where p.available_from < (NOW() - INTERVAL 1 MONTH)
and p.product_id not in (
select o.product_id
from Orders as o
where o.dispatch_date > (NOW() - INTERVAL 1 YEAR)
group by o.product_id
having sum(o.quantity) >= 10
)
import pandas
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
matplotlib.style.use('ggplot')
df = pandas.read_excel('results.xls')
df.set_index("Candidate Number", inplace=True)
package comp207p.main;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.*;
import org.apache.bcel.util.InstructionFinder;
import org.apache.bcel.verifier.structurals.ControlFlowGraph;
@anirudhpillai
anirudhpillai / Tableau
Last active February 26, 2017 19:07
A REPL which tells if a given propositional formula is satisfiable or not.
import Text.ParserCombinators.Parsec hiding (spaces)
import System.Environment
import System.IO
-- Data types
data Formula = Proposition Char
| Negation Formula
| Binary Connective Formula Formula
#include "simpletools.h"
#include "ping.h"
#include "abdrive.h"
#define PAUSE 950
#define speed 50
#define pid_fac 2
#define SIDE 40
#define NORTH 0
#define EAST 1
#define SOUTH 2
import ast
import sys
class Vending_Machine:
def __init__(self, products, change):
self.products = products
self.change = change
def reset_products(self):
print("Let's reload the products")
import sys
class Room:
def __init__(self, name, description):
self.name = name
self.items = []
self.exits = []
self.description = description
def __str__(self):