Skip to content

Instantly share code, notes, and snippets.

View MitI-7's full-sized avatar

MitI_7 MitI-7

View GitHub Profile
@MitI-7
MitI-7 / switch_bot.py
Created May 5, 2020 08:33
switch bot on windows
import asyncio
import binascii
from bleak import BleakClient, BleakScanner
COMMUNICATION_SERVICE_UUID = "cba20d00-224d-11e6-9fb8-0002a5d5c51b"
RX_CHARACTERISTIC_UUID = "cba20002-224d-11e6-9fb8-0002a5d5c51b"
TX_CHARACTERISTIC_UUID = "cba20003-224d-11e6-9fb8-0002a5d5c51b"
PRESS = "PRESS"
ON = "ON"
Optimal - objective value 13.00000000
4 X0000004 8 0
11 X0000011 6 0
23 X0000023 7 0
32 X0000032 10 0
40 X0000040 11 0
56 X0000056 13 0
68 X0000068 6 0
74 X0000074 2 0
75 X0000075 11 0
from pulp import *
def solve(initial_solution_file_path: str=None):
left = list(range(10))
right = list(range(10))
route = [(i, j) for i in left for j in right]
supply = [8, 6, 7, 10, 11, 13, 6, 13, 14, 12]
demand = [11, 11, 10, 7, 10, 11, 13, 9, 9, 9]
@MitI-7
MitI-7 / pure_fixed_charge_transportation_problem.py
Last active January 25, 2019 06:51
pure fixed charge transportation problem
from pulp import *
def solve():
left = list(range(10))
right = list(range(10))
route = [(i, j) for i in left for j in right]
supply = [8, 6, 7, 10, 11, 13, 6, 13, 14, 12]
demand = [11, 11, 10, 7, 10, 11, 13, 9, 9, 9]
@MitI-7
MitI-7 / FactorizationMachines.py
Created January 22, 2019 15:32
FactorizationMachines
import numpy as np
from math import exp, log
def sigmoid(x):
return 1 / (1 + exp(-x))
class FactorizationMachines:
def __init__(self, epoch: int=1000, k: int=3, eta: float=0.01, seed: int=0):
@MitI-7
MitI-7 / sa
Created February 6, 2018 13:12
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define LL long long
#define LOG(c) logger.log(c);
@MitI-7
MitI-7 / burrows_wheeler_transform.py
Last active July 28, 2017 10:58
burrows_wheeler_transform
def burrows_wheeler_transform(s: str) -> str:
assert s.count("$") == 1
n = len(s)
table = [[None] * n for _ in range(n)]
for i in range(n):
for j in range(n):
table[i][j] = s[(i + j) % n]
table.sort()
@MitI-7
MitI-7 / weather.py
Created February 20, 2017 10:59
天気予報の取得
import json
import urllib.request
def main():
jsonp = urllib.request.urlopen("http://www.drk7.jp/weather/json/13.js").read().decode("utf-8")
data = json.loads(jsonp.replace("drk7jpweather.callback(", "")[:-2])
for j in data["pref"]["area"]["東京地方"]["info"]:
date = j["date"]
rainfall_chance = j["rainfallchance"]
@MitI-7
MitI-7 / sa.cpp
Last active September 7, 2016 13:43
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <algorithm>