Skip to content

Instantly share code, notes, and snippets.

View adrian17's full-sized avatar

Adrian Wielgosik adrian17

View GitHub Profile
@adrian17
adrian17 / main.cpp
Last active August 24, 2016 22:20
slightly simpler and slower anagram generator implementation
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <array>
#include <fstream>
#include <xmmintrin.h>
#include <experimental/string_view>
using namespace std;
using namespace std::experimental;
@adrian17
adrian17 / main.cpp
Created July 25, 2016 21:26
concepts diagn
template<typename T> using id=T;
template<typename T>
concept bool A = requires(T a) { a==a; };
template<typename T, typename U>
concept bool B =
A<T> && // (1) basic usage
A<T> && // (2) duplicate concept check
A<U> && // (3) different concept check that happens to work on the same type here
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) {