Skip to content

Instantly share code, notes, and snippets.

@medecau
medecau / calldict.py
Last active February 20, 2021 08:52
Callable dictionary
class callable_dict(dict):
def __call__(self, **kwargs):
nd = self.copy()
nd.update(**kwargs)
return nd
d = callable_dict(a=1, b=2)
nd = d(b=3, c=4)
print(d)
print(nd)
add_library('Drop')
from drop import SDrop, DropListener
drop = None
img = None
class DropyListener(DropListener):
def dropEvent(self, e):
global img
if e.isImage():
from sys import argv
from glob import glob
from itertools import imap, chain, ifilter, groupby
from collections import defaultdict
from PyPDF2 import PdfFileReader
from pattern.en import parsetree
def ilen(i):
"""
@medecau
medecau / gist:946348
Created April 28, 2011 13:31
Processing controlP5 round button
import controlP5.*;
ControlPad cp;
ControlP5 controlP5;
void setup() {
size(400, 400);
frameRate(30);
smooth();
@medecau
medecau / gist:942818
Created April 26, 2011 18:34
Earth Savers
int position, speed, health, pSize;
int asteroidInterval, asteroidCounter;
ArrayList asteroids, bullets;
void setup(){
size(400,600);
import fisica.*;
import processing.video.MovieMaker;
//MovieMaker mm;
FWorld world;
void setup(){
size(800,600);
smooth();
import fisica.*;
//import processing.video.MovieMaker;
//MovieMaker mm;
FWorld world;
void setup(){
size(800,600);
smooth();
ENGINEERING PROBLEM #2:
Our marketing department has just negotiated a deal with several of the top local
merchants that will allow us to offer exclusive discounts on various products to our top
customers every day. The catch is that we may only offer each product to one customer
and we may only make one offer to each customer.
Each day we will get the list of products that are eligible for these special discounts. We
then have to decide which products to offer to which customers. Fortunately our team
of highly trained statisticians has developed an amazing mathematical model for
determining which customers are most likely to buy which products.
With all of the hard work done for us, all we have to do now is implement a program
@medecau
medecau / opcp.md
Last active March 7, 2024 18:11
Online Programming Contests and Puzzles
1. Datacenter Cooling
We have some rooms in our datacenter, and we need to connect them all with a single cooling duct.
Here are the rules:
The datacenter is represented by a 2D grid.
Rooms we own are represented by a 0.
Rooms we do not own are represented by a 1.
The duct has to start at the air intake valve, which is represented by a 2.
The duct has to end at the air conditioner, which is represented by a 3.