Skip to content

Instantly share code, notes, and snippets.

View cocomoff's full-sized avatar
🏠
Working from home

Keisuke OTAKI cocomoff

🏠
Working from home
View GitHub Profile
@cocomoff
cocomoff / rust_antenna_greedy.rs
Created April 22, 2020 01:47
Rust アンテナ選択 貪欲
use rand::{Rng, thread_rng};
use rand::distributions::{Uniform};
use std::collections::{HashMap, HashSet};
#[allow(dead_code)]
struct Env {
rg: f32, // ランダム位置範囲 (-rg, rg)
n: usize, // アンテナ数
r: f32, // アンテナの半径
a: Vec<[f32; 2]>, // アンテナの位置
@cocomoff
cocomoff / main.rs
Last active April 8, 2020 13:53
Rust何も分からない練習帳
use rand::distributions::{Bernoulli, Distribution};
use rand::prelude::*;
// Armは以下の機能を持つ
// - 報酬を観察できる
trait Arm {
fn draw(&self) -> f64;
}
// ベルヌーイ分布に従うarm
@cocomoff
cocomoff / julia_dijkstra_example.jl
Created February 18, 2020 09:03
JuliaのDataStructures.jlを利用したDijkstra法の実装例(C++ -> Julia)
# -*- coding: utf-8 -*-
module Dijkstra
using DataStructures
mutable struct Edge
to::Int
cost::Int
end
@cocomoff
cocomoff / line_segment_intersect.py
Created December 11, 2019 09:24
segments and intersect
def line_segment_intersection(p1, p2, p3, p4):
d = (p2[0] - p1[0]) * (p4[1] - p3[1]) - (p2[1] - p1[1]) * (p4[0] - p3[0])
if d == 0.0:
return None
intersect = [0.0, 0.0]
u = ((p3[0] - p1[0]) * (p4[1] - p3[1]) - (p3[1] - p1[1]) * (p4[0] - p3[0])) / d
v = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / d
if u < 0.0 or u > 1.0 or v < 0.0 or v > 1.0:
return None
@cocomoff
cocomoff / dFrechet.ipynb
Created December 4, 2019 07:11
example of module
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cocomoff
cocomoff / edge.txt
Created December 3, 2019 15:41
Plots in Julia for graph visualizer (tentative)
1 2
1 3
2 4
3 4
3 5
4 5
@cocomoff
cocomoff / public.rs
Created September 24, 2019 15:46
tekitou public
use fast_paths::InputGraph;
use fast_paths::PreparationGraph;
use fast_paths::Dijkstra;
use fast_paths::contract_node;
fn main() {
let mut input_graph = InputGraph::new();
// // 01234=ABCDE
// input_graph.add_edge_bidir(0, 2, 1);
// input_graph.add_edge_bidir(1, 2, 4);
@cocomoff
cocomoff / public.rs
Created September 24, 2019 15:46
tekitou public
use fast_paths::InputGraph;
use fast_paths::PreparationGraph;
use fast_paths::Dijkstra;
use fast_paths::contract_node;
fn main() {
let mut input_graph = InputGraph::new();
// // 01234=ABCDE
// input_graph.add_edge_bidir(0, 2, 1);
// input_graph.add_edge_bidir(1, 2, 4);
@cocomoff
cocomoff / index.html
Created August 26, 2019 09:53
bokeh example (index template)
<!DOCTYPE html>
<html>
<head>
<title>Flask Bokeh Sample</title>
{% autoescape False %}
{{ resources }}
{% endautoescape %}
</head>
<body>
@cocomoff
cocomoff / bokeh_example.py
Created August 26, 2019 09:52
bokeh example
# -*- coding: utf-8 -*-
import json
from bokeh.embed import json_item
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.sampledata.iris import flowers
from bokeh.embed import components
from bokeh.plotting import figure
from flask import Flask, render_template