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
#include <iostream> // cout | |
#include <algorithm> // transform | |
#include <vector> // vector | |
using namespace std; | |
void print (int i) { cout << ' ' << i; } | |
struct c_unique { | |
int current; | |
// constructor |
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 java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
public class ImageViewer implements KeyListener{ | |
private JFrame frame; | |
private ImageIcon image; | |
private ImageIcon origImage; | |
private JLabel imageLabel; | |
private String[] files; | |
private int index; |
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
# Signal handler example. Debugger starts with Ctrl-C: | |
import signal | |
def int_handler(signal, frame): | |
import pdb | |
pdb.set_trace(frame) | |
signal.signal(signal.SIGINT, int_handler) | |
# Put that at the top of your script and you can start debugging your script at any | |
# point by type Ctrl-C. Resume programe execution by typing exit at the Pdb prompt. |
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/env python3 | |
''' | |
Perlin noise generator based on pseudocode from | |
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm | |
''' | |
import math | |
def linear_interp(a, b, x): | |
return a * (1 - x) + b * x |
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/env python3 | |
import math | |
class Point: | |
def __init__(self, x=0, y=0): | |
self.x = x | |
self.y = y | |
def __repr__(self): | |
return 'Point({0.x}, {0.y})'.format(self) |
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 pygame | |
from pygame.locals import * | |
#http://ezide.com/games/writing-games.html | |
DIRECTION_UP = 0 | |
DIRECTION_DOWN = 1 | |
DIRECTION_LEFT = 2 | |
DIRECTION_RIGHT = 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
######################################################################## | |
import operator | |
import math | |
class Vec3d(object): | |
"""3d vector class, supports vector and scalar operators, | |
and also provides a bunch of high level functions. | |
reproduced from the vec2d class on the pygame wiki site. |
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 pygame | |
import atexit | |
pygame.init() | |
atexit.register(pygame.quit) | |
size = width, height = 500,500 | |
black = 0, 0, 0 | |
white = 0xff, 0xff, 0xff |
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
def main(): | |
pass | |
if __name__ == '__main__': | |
import doctest | |
failure_count, test_count = doctest.testmod() | |
if failure_count == 0: | |
main() |
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/env python3 | |
from math import ceil | |
def base_area(n, width, length, height): | |
return n * ( 2 * width * height + 2 * length * height + length * width) | |
def run_case(in_it): | |
n, width, length, height, area, m = next(in_it).split() | |
n = int(n) | |
width = int(width) |