Skip to content

Instantly share code, notes, and snippets.

View nariaki3551's full-sized avatar

Nariaki Tateiwa nariaki3551

  • NTT Software Innovation Center
  • Tokyo
View GitHub Profile
use std::io::Write;
fn main() {
// setting hardcoding
let pin_num = 2; // number of pins
let color_num = 3; // number of colors
let duplicate = false; // code dose not have same colors
println!(
"Context: pin_num: {}, color_num: {}, duplicate: {}",
pin_num, color_num, duplicate
use std::io::Write;
fn main() {
// temporary setting
let pin_num = 2; // number of pins
let color_num = 3; // number of colors
let duplicate = false; // code dose not have same colors
println!(
"Context: pin_num: {}, color_num: {}, duplicate: {}",
pin_num, color_num, duplicate
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from heapq import heapify, heappush, heappop, heappushpop
def beam_search(root, k, api):
"""
Args:
root : root node
k : number of remain paths during search
api : apis for beam search
Notes:
api must have functions as follows.
#!/usr/bin/env python
# coding: utf-8
import enum
import itertools
import collections
import argparse
import numpy as np
import pulp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import re
import argparse
import pandas as pd
import matplotlib.pyplot as plt
integer = "[0-9]+"
double = "[0-9]+\.*[0-9]*"
_double = "[0-9]+\.[0-9]+([eE][+-]?[0-9]+)"
depth = 3
tree = [i for i in range(2**depth-1)]
def path_generator(node_ix):
if node_ix >= 2**(depth-1) - 1: # leaf node
yield [node_ix]
else:
for path in _dfs(2*node_ix+1): # left child
yield [node_ix] + path
for path in _dfs(2*node_ix+2): # right child