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
#!/usr/bin/python | |
# coding: utf8 | |
######################### | |
# # | |
# _______________ # | |
# | | # | |
# | -*- | # | |
# | Hack la viva! | # | |
# | ______________| # |
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
/* | |
* simple example of a synthesizer | |
*breadboard schematics: http://www.flickr.com/photos/28914418@N02/3751185789/sizes/o/ | |
* | |
* rights: http://tinyurl.com/by-sa-3-0 | |
*/ | |
int speakerPin = 9; | |
int tempo = 0; | |
int potPin1 = 0; | |
int potVal1 = 0; |
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
/** | |
* code to read one quadratic rotary encoder gray code. | |
* | |
* rights: http://tinyurl.com/by-sa-3-0 | |
*/ | |
int inputPin1 = 2; // A | |
int inputPin2 = 4; // B | |
int val1 = 0, val2 = 0; | |
int oldVal1 = 0, oldVal2 = 0; |
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
$ python string_exercise.py | |
The haystack has 9 words. | |
Is there a "fox" in the haystack? | |
True | |
Leave the poor dog alone fox! | |
The quick brown fox jumps over the lazy programmer |
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. |
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
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
int position, speed, health, pSize; | |
int asteroidInterval, asteroidCounter; | |
ArrayList asteroids, bullets; | |
void setup(){ | |
size(400,600); |
OlderNewer