Skip to content

Instantly share code, notes, and snippets.

@medecau
medecau / gist:75393
Created March 7, 2009 17:35
tutorial de python
#!/usr/bin/python
# coding: utf8
#########################
# #
# _______________ #
# | | #
# | -*- | #
# | Hack la viva! | #
# | ______________| #
/*
* 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;
/**
* 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;
$ 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
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.
@medecau
medecau / opcp.md
Last active March 7, 2024 18:11
Online Programming Contests and Puzzles
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
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();
@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);