Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Keisuke OTAKI cocomoff

🏠
Working from home
Block or report user

Report or block cocomoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cocomoff
cocomoff / run.sh
Created Jul 17, 2019
dot-png generator
View run.sh
#!/bin/zsh
for l in `ls output/*.dot`;
do
fname=${l:r}.png;
dot -Tpng $l > $fname;
done;
View example_tdzdd.cpp
#include <fstream>
#include <iostream>
#include <tdzdd/DdSpec.hpp>
#include <tdzdd/DdStructure.hpp>
using namespace std;
const bool DEBUG_ENUM = false;
class Combination : public tdzdd::DdSpec<Combination, int, 2> {
@cocomoff
cocomoff / example_tdzdd_01knapsack.cpp
Created Jul 8, 2019
example_tdzdd_01knapsack.cpp
View example_tdzdd_01knapsack.cpp
#include <fstream>
#include <iostream>
#include <tdzdd/DdSpec.hpp>
#include <tdzdd/DdStructure.hpp>
using namespace std;
class KnapsackZdd : public tdzdd::DdSpec<KnapsackZdd, int, 2> {
int const n;
int const *w;
View multidag_longest_path.py
# -*- coding: utf-8 -*-
import networkx as nx
import networkx.algorithms as nxa
def longest_path_for_multidigraph(G, weight='weight', default_weight=1):
dist = {}
for v in nx.topological_sort(G):
us = []
for u, data in G.pred[v].items():
@cocomoff
cocomoff / example_bdd_constraint_var18.cpp
Created Jul 4, 2019
example_bdd_constraint_var18.cpp
View example_bdd_constraint_var18.cpp
#include <iostream>
#include <random>
#include <vector>
#include "cuddObj.hh"
using namespace std;
int main() {
Cudd mgr;
@cocomoff
cocomoff / example_bdd_constraint.cpp
Last active Jul 4, 2019
example_bdd_constraint.cpp
View example_bdd_constraint.cpp
#include <iostream>
#include <random>
#include <vector>
#include "cuddObj.hh"
using namespace std;
int main() {
Cudd mgr;
@cocomoff
cocomoff / example_wt.cpp
Created Jul 3, 2019
wavelet tree of integer values
View example_wt.cpp
#include <bits/stdc++.h>
#include <sdsl/wavelet_trees.hpp>
using namespace std;
using namespace sdsl;
int main() {
wt_int<rrr_vector<63>> wt;
// auto iv = int_vector<>({0, 7, 2, 1, 4, 3, 6, 7, 2, 5, 0, 4, 7, 2, 6, 3});
auto iv = int_vector<>({0, 2, 1, 3, 2, 0, 2, 3});
@cocomoff
cocomoff / example_bs.cpp
Created Jun 30, 2019
bit vector example
View example_bs.cpp
/*
g++ -std=c++14 -o main main.cpp -I/home/cocomoff/sdsl-lite/build/include -L/home/cocomoff/sdsl-lite/build/lib -lsdsl -ldivsufsort -ldivsufsort64
*/
#include <bits/stdc++.h>
#include <sdsl/int_vector.hpp>
#include <sdsl/bit_vectors.hpp>
#include <sdsl/rank_support.hpp>
#include <sdsl/util.hpp>
@cocomoff
cocomoff / several_coding_examples.py
Created Jun 19, 2019
高速文字列解析の世界 §2.5 符号
View several_coding_examples.py
# -*- coding: utf-8 -*-
def unary(x):
return "0" * (x - 1) + "1"
def binary(x):
return bin(x)[2:]
def gamma(x):
bx = binary(x)
View simple_BWT.py
# -*- coding: utf-8 -*-
if __name__ == '__main__':
T = "abracadabra$"
lT = len(T)
print("Input:", T)
sa = [T[i:] for i in range(lT)]
isa = list(zip(range(lT), sa))
sorted_isa = sorted(isa, key=lambda x: x[1])
You can’t perform that action at this time.