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
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) |
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
add_library('Drop') | |
from drop import SDrop, DropListener | |
drop = None | |
img = None | |
class DropyListener(DropListener): | |
def dropEvent(self, e): | |
global img | |
if e.isImage(): |
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
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): | |
""" |
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
import controlP5.*; | |
ControlPad cp; | |
ControlP5 controlP5; | |
void setup() { | |
size(400, 400); | |
frameRate(30); | |
smooth(); |
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
int position, speed, health, pSize; | |
int asteroidInterval, asteroidCounter; | |
ArrayList asteroids, bullets; | |
void setup(){ | |
size(400,600); |
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
import fisica.*; | |
import processing.video.MovieMaker; | |
//MovieMaker mm; | |
FWorld world; | |
void setup(){ | |
size(800,600); | |
smooth(); | |
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
import fisica.*; | |
//import processing.video.MovieMaker; | |
//MovieMaker mm; | |
FWorld world; | |
void setup(){ | |
size(800,600); | |
smooth(); | |
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
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 |
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
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. |