Skip to content

Instantly share code, notes, and snippets.

from functools import reduce
from operator import mul
# pip install pycrypto
from Crypto.Util.number import getRandomNBitInteger, isPrime
from Crypto.PublicKey import RSA
def first_n_primes(n):
primes = [2]
from time import sleep
class Cell:
ALIVE = True
DEAD = False
def __init__(self, status):
self.status = status
from random import choice
BOARD_SIZE = 5
class Node:
def __init__(self):
self.value = 0
self.children = {}
class Board:
WIDTH = 9
HEIGHT = 9
def __init__(self):
self.squares = [
[5, 3, None, None, 7, None, None, None, None],
[6, None, None, 1, 9, 5, None, None, None],
[None, 9, 8, None, None, None, None, 6, None],
[8, None, None, None, 6, None, None, None, 3],
// empty.h
class Empty {
// this class declares no members but still will implicitly have the
// below declared by the compiler (in the public scope)
/*
Empty(){...} // default constructor
Empty(const Empty& rhs){...} // copy constructor
~Empty(){...} // default destructor
Empty& operator=(const Empty& rhs){...} // copy assignment operator
// house.h
class House {
//copying a house doesn't make much sense so disallow use of copy functions
private:
House(const House&); // copy constructor
House& operator=(const House&); // copy assignment
};
// main.cpp
int main(int argc, char * argv[]) {
// timeKeeper.h
class TimeKeeper {
public:
TimeKeeper();
~TimeKeeper(); // note the virtual keyword is missing
};
// wristWatch.h
class WristWatch : public TimeKeeper {
#include <stdlib.h>
#include <vector>
class Bad {
public:
~Bad(){ throw 0; }
};
int main() {
Bad b1, b2;
class Node:
def __init__(self, key, data):
self.next = None
self.prev = None
self.key = key
self.data = data
class LinkedList:
def __init__(self):
class Node:
def __init__(self, data, prev, next):
self.data = data
self.prev = prev
self.next = next
class DoubleLinkedList:
def __init__(self):
self.head = None