Skip to content

Instantly share code, notes, and snippets.

View adrian17's full-sized avatar

Adrian Wielgosik adrian17

View GitHub Profile
class Node:
def __init__(self, val):
self.up = bool(val & 1)
self.right = bool(val & 2)
self.down = bool(val & 4)
self.left = bool(val & 8)
def rotate(self):
self.up, self.right, self.down, self.left = self.right, self.down, self.left, self.up
def num(self):
return self.up<<0 | self.right<<1 | self.down<<2 | self.left<<3
@adrian17
adrian17 / STL.cpp
Last active March 25, 2016 19:56
Examples for "make pointers to members callable"
// and it works with standard algorithms out of the box
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>
struct S{
S(){static int N; val = N++;}
void f(){std::cout << " " << val << "\n";}
from marisa_trie import Trie
valid_squares = []
def recurse():
for row in row_words:
yield from recurse_col((row,), (), 1, 0)
def recurse_row(rows, cols, y, x):
for i in range(y, H):
asdf
14874
0 L 4 992 1
0 D 115 992 1
0 L 4 508 1
0 L 4 1300 1
0 D 838 508 1
0 D 838 1300 1
0 L 0 1087 1
0 L 0 1328 1
0 D 295 1087 1
@adrian17
adrian17 / main.py
Last active February 10, 2016 14:13
80
PAINT_LINE 24 63 24 87
PAINT_LINE 29 113 32 113
PAINT_SQUARE 32 171 1
PAINT_LINE 14 116 23 116
PAINT_SQUARE 19 101 5
PAINT_SQUARE 27 138 2
PAINT_SQUARE 28 60 3
PAINT_LINE 25 191 28 191
PAINT_SQUARE 27 175 2
@adrian17
adrian17 / painting.py
Last active February 10, 2016 12:36
Painting
import time
wh, *macierz = open("logo.in").read().splitlines()
wh, *macierz = open("right_angle.in").read().splitlines()
wh, *macierz = open("learn_and_teach.in").read().splitlines()
H, W = map(int, wh.split())
def banalny(macierz, transponowana=False):
if transponowana:
@adrian17
adrian17 / main.cpp
Last active December 19, 2015 00:30
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <arpa/inet.h>
#include <endian.h>
unsigned to_num(const std::string& ip) {
64 - Kip Ballard
61 - Adjournment PLC
60 - Democratic Republic of Mead
58 - Cellist LLC
58 - University of Noway
56 - National Markedly Funnest
56 - Davenport Versailles
56 - Hurst Wilmington
56 - Palsying Scowls Union
56 - Salyut Apple
119.200.220.130 Democratic Republic of Superhighways Loathings
235.130.216.53 Laughing Plows Party
232.235.154.169 Center for Oligarchies
180.36.238.209 United Fowl Rejoinder
142.176.207.13 Salyut Apple
72.167.76.141 Shrugged Oversimplifies Institute
109.17.148.205 United Gangplank
221.189.18.4 Surmountable Inc
246.152.207.6 Downbeats LLC
123.85.237.38 Hurst Wilmington