Skip to content

Instantly share code, notes, and snippets.

View bgnori's full-sized avatar

Noriyuki Hosaka bgnori

  • Itabashi, Tokyo, Japan
View GitHub Profile
import numpy as np
def redbrain(n=100, b=0.3, sz=100):
return [(x, np.random.binomial(n - x, b)) for x in np.random.binomial(n, 0.5, sz)]
def foo(n, sz):
d = {}
for i in range(1, 20):
p = i * 0.05
xs = redbrain(n=n, b=p, sz=sz)
{
"Total DeltaV": 7751.744428756014,
"Total Weight": 341697,
"name": "Minmus Miner, launch from Kerbin to LKO",
"stages": [
{
"fuel": 0,
"Wet": 0,
"name": "Ore",
"mt": 0,
import math
import json
from itertools import starmap
def tonne(x):
return x*1000.0
def deltaV(Isp, m0, mt, gravitational_acc=9.80665):
"""
@bgnori
bgnori / swamp.py
Last active October 25, 2017 09:01
import collections
m = [[-1,1,1,-1,-1,1,1,-1,-1,1],[1,"S",1,"L",-1,-1,-1,-1,-1,-1],[-1,-1,-1,1,1,-1,1,-1,1,1],[1,"L",-1,-1,1,-1,1,-1,1,-1],[-1,1,1,-1,-1,-1,-1,"L",1,-1],[1,-1,1,-1,-1,1,-1,1,-1,1],[-1,"L",-1,-1,-1,1,-1,-1,-1,1],[-1,1,-1,1,1,-1,1,-1,-1,-1],[-1,1,-1,-1,-1,1,1,-1,"G",1],[-1,-1,1,1,-1,-1,-1,1,-1,-1]]
print(m)
class Position(collections.namedtuple("Position", ['x', 'y'])):
__slots__ = ()
ws = ["イアラ","ウェイト","オメガロ","ガルヒ","ガングリオンズ","クリオ","ジェノバ","スノウガ","ズビズバ","スペシウム","タグアズ","ドドンパ","トルネ","ネメシス","バイナリル","ハザード","パリピファイア","バルース","ヒラケゴマ","フェイク","プリズマ","ホルーガ","マッハ","マホマホ","ムート","ラリホフ","ランス","ループ","ロールウェイブ","ワロス"]
conn = {}
for w in ws:
for v in ws:
if w[-1] == v[0]:
conn[(w, v)] = True
print(conn)
# coding: utf-8
import itertools
def baz(xs, n):
ys = list(itertools.zip_longest(xs[n::4], xs[n+1::4], fillvalue=' '))
zs = itertools.zip_longest(ys[0::4], ys[1::4], ys[2::4], ys[3::4], fillvalue=(' ', ' '))
return [[p for ps in z for p in ps] for z in zs]
xs = [chr(i) for i in range(ord('a'), ord('z')+1)]
@bgnori
bgnori / hrm.py
Created July 3, 2017 07:09
ヒューマンリソースマシーン Year 10までなんとなく検証(入力がわからないので)
import io
from enum import Enum, auto
class Inst(Enum):
inbox = auto()
outbox = auto()
python3 ShogiELOtourney.py --verbose --resolve --tournament ryuuou30th-2.json --out expected-r1750.json --override 307:1750
[
[
"村山慈明(id=249, r=1721)",
0.0028835519066684858
],
[
"渡辺明(id=235, r=1849)",
0.5997696089008129
],
[
def isprime(n):
for i in range(2, n):
if n % i == 0:
return False
return True
class Counter:
def __init__(self, n):