Skip to content

Instantly share code, notes, and snippets.

use csv;
use std::fs::File;
use itertools::Itertools;
#[derive(Clone, Copy, Debug, PartialEq)]
enum Operator {
Add,
Sub,
Mult,
Div
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>
#include <array>
#include <stdio.h>
using namespace std;
using namespace cv;
import requests
from bs4 import BeautifulSoup
print("伝票番号を入力してください")
denpyo_id = input()
response = requests.post('http://toi.kuronekoyamato.co.jp/cgi-bin/tneko', data={'number01':denpyo_id })
soup = BeautifulSoup(response.text, "html.parser")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@terakun
terakun / quoridorclient.py
Created May 1, 2019 17:59
QuoridorのPythonクライアントのテンプレート
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
port = 8080
ip = '127.0.0.1'
# サーバ/ポートを指定
s.connect((ip, port))
while True:
mesg = s.recv(1024) # メッセージを受信 (https://github.com/terakun/quoridor_judgeの入力形式に対応するバイト列が送られてくる)
print(mesg)
#!/bin/sh
IMAGE=paperist/alpine-texlive-ja
exec docker run --rm -i --user="$(id -u):$(id -g)" --net=none -v "$PWD":/data "$IMAGE" "$@"
import numpy as np
from scipy.stats import t as student_t
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
def student(n):
samples = np.random.normal(0,1,n)
mean = np.mean(samples)
unbiased_var = np.var(samples, ddof=1)
return np.sqrt(n/unbiased_var)*mean
@terakun
terakun / opt.py
Created December 6, 2018 12:14
optunaを使って他プログラムのパラメータを最適化する
#!/usr/bin/python
# coding: UTF-8
# 実行ファイルはコマンドライン引数としてパラメータを受け取り,目的関数値のみを標準出力に出力するものとする
# $ ./a.out 1.2 10
# 42
# configファイルには
# [varname] [vartype] [range]
# を書いておく
@terakun
terakun / tic_tac_toe.rs
Created November 13, 2018 18:06
モンテカルロ法で三目並べの勝率計算
extern crate rand;
use rand::{thread_rng, Rng};
fn end(board: &Vec<i32>) -> usize {
// 縦
for i in 0..3 {
let mut sum = 0;
for j in 0..3 {
sum = sum + board[i * 3 + j];
}
@terakun
terakun / Makefile
Created November 12, 2018 13:44
c++ Makefile
CXX = g++
FLAGS = -std=c++1z -Ofast -march=native
INCLUDES =
LIBS =
TARGET = main
SRCS = main.cc
OBJS = $(patsubst %.cc,%.o,$(SRCS))
.cc.o:
$(CXX) $(FLAGS) $(INCLUDES) -c $< -o $@