Skip to content

Instantly share code, notes, and snippets.

View zaltoprofen's full-sized avatar

nakashima zaltoprofen

  • Tokyo, Japan
View GitHub Profile
#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))
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template<typename T, typename Func>
class lazy_segtree {
struct node{
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']
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,
#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) {
(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 '(寝 る)))
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]
# -*- 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):
/*
* Minimum spanning tree
* Kruskal's algorithm
*/
#include <iostream>
#include <vector>
#include <algorithm>
class UnionFind {
private:
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("帰", "る")