This file contains hidden or 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
#from PIL import Image, ImageDraw | |
from svgwrite import Drawing, rgb | |
from cmath import tan, pi | |
import hashlib | |
a = hashlib.sha256(input('key: ').encode('utf-8')) | |
digest = a.digest() | |
#img = Image.new('RGBA', (256, 256), (255, 255, 255, 255)) | |
#draw = ImageDraw.Draw(img, 'RGBA') | |
draw = Drawing('icon.svg', size=(256, 256)) |
This file contains hidden or 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> | |
#include <vector> | |
#include <algorithm> | |
#include <string> | |
using namespace std; | |
template<typename T, typename Func> | |
class lazy_segtree { | |
struct node{ |
This file contains hidden or 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
from configparser import ConfigParser | |
from twitter import Twitter, OAuth | |
from datetime import datetime, timezone | |
import json | |
conf = ConfigParser() | |
conf.read('config.ini') | |
oauthconf = conf['oauth'] |
This file contains hidden or 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
with recursive zero100(z, i) as ( | |
values(0, 0) | |
union all | |
select 0, i+1 from zero100 where i+1 < 100 | |
), vm(step, sout, pc, ins, p, mem, stack) as ( | |
values(0, '', 1, '+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.', | |
1, (select array_agg(z) from zero100), array[]::int[]) | |
union all | |
select | |
step + 1, |
This file contains hidden or 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> | |
#include <vector> | |
#include <unordered_set> | |
#include <set> | |
#include <utility> | |
using namespace std; | |
struct not_dag{}; | |
vector<int> tsort(unordered_set<int> s, set<pair<int, int>> e) { |
This file contains hidden or 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
(define (power s) | |
(define (power-rec a b) | |
(cond | |
((null? a) b) | |
(else (power-rec (cdr a) (append (map (lambda (x) (cons (car a) x)) b) b))))) | |
(map reverse (power-rec s '(())))) | |
(use srfi-27) | |
(random-source-randomize! default-random-source) | |
(define ps (power '(寝 る))) |
This file contains hidden or 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 System.Random | |
power :: [a] -> [[a]] | |
power xs = let | |
go [] ys = ys | |
go (x:xs) ys = go xs $ map (\a -> a ++ [x]) ys ++ ys | |
in | |
go xs [[]] | |
pickRand :: RandomGen r => r -> [a] -> [a] |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
from itertools import chain, tee | |
from functools import reduce | |
class powerset(object): | |
def __init__(self, orig): | |
self._s = list(orig) | |
self._b = [False for _ in orig] | |
def __iter__(self): |
This file contains hidden or 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
/* | |
* Minimum spanning tree | |
* Kruskal's algorithm | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
class UnionFind { | |
private: |
This file contains hidden or 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
object Application extends App { | |
def power[A](s: Set[A]): Set[Set[A]] = { | |
@annotation.tailrec | |
def go(a: Set[A], b: Set[Set[A]]): Set[Set[A]] = { | |
if (a.isEmpty) b | |
else go(a.tail, b.map(_ + a.head) ++ b) | |
} | |
go(s, Set(Set())) | |
} | |
val s = Set("帰", "る") |