Skip to content

Instantly share code, notes, and snippets.

use std::collections::HashMap;
fn greet_map(id: usize, name: String) -> HashMap<usize, String> {
let mut map = HashMap::new();
let message = format!("Hello, {}!", name);
map.insert(id, message);
map
}
fn main() {
@mizar
mizar / png_out.py
Last active January 3, 2024 05:42 — forked from darka/png_out.py
Generating a PNG in Python
import base64, io, struct, zlib
from typing import BinaryIO, List, Tuple, Union
COLOR_TYPE_V = 0
COLOR_TYPE_VA = 4
COLOR_TYPE_RGB = 2
COLOR_TYPE_RGBA = 6
PixelV = Tuple[int]
PixelVA = Tuple[int, int]
@mizar
mizar / eratosthenes.rs
Last active December 10, 2022 15:51
高速なエラトステネスの篩 https://github.com/peria/primes/tree/master/eratosthenes の Rust版
// -*- coding:utf-8-unix -*-
//! エラトステネスの篩 & 生成した素数の試し割りによる素因数分解
//!
//! ## 素因数分解の実行例
//!
//! [`main`] を参照
//!
//! ## ベンチマーク実行例
//!
@mizar
mizar / vrc-lt-converter_4k.ipynb
Last active September 20, 2022 16:07
vrc-lt-converter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / legal_policy.md
Last active June 17, 2022 17:48
将棋: 合法手として成立しうる駒の移動先と移動方向のパターンの数え上げ
@mizar
mizar / .gitattributes
Last active August 20, 2022 14:56
将棋AI:USIエンジン:Policyプレイヤー
* text=auto
*.bat text eol=crlf
*.cmd text eol=crlf
*.sh text eol=lf
*.onnx -text
*.zip -text
@mizar
mizar / .gitattributes
Last active May 31, 2022 15:06
将棋AI:USIエンジン:ランダムプレイヤー
* text=auto
*.bat text eol=crlf
*.cmd text eol=crlf
*.sh text eol=lf
@mizar
mizar / usiengine_flow.md
Last active May 28, 2022 09:18
将棋AI:USIエンジン遷移遷移図(抄)

USIエンジン状態遷移図(抄)

graph LR;
flowstart((起動)) -->|usi| usioption[/option/] --> usiok[/usiok/] --> usimode((USIモード)) -->|isready| isready[初期化処理] --> readyok[/readyok/] --> ready((初期化済み))
--> |usinewgame| ingame((対局中));
usimode -->|setoption| setoption[オプション設定] --> usimode;
ingame -->|go| search((探索)) -->|"(探索完了)"| bestmove[/bestmove/] --> ingame;
ingame -->|position| setposition[局面設定] --> ingame;
search -->|stop| bestmove;

👇

$$ \operatorname{I}x(a,b)=\dots, d{2n}=\dots $$

👆

$$ \operatorname{I}_x(a,b)=\dots, d_{2n}=\dots $$
@mizar
mizar / ki2moveformat.md
Last active March 6, 2022 03:15
将棋の棋譜表記方法(伝統形式)

将棋の棋譜表記方法(伝統形式)

全体

graph LR;
flowstart((start)) --> A((基本<br>start)) --> At{手番の記号を出力するか} --> |手番の記号なし| Atn["手番の記号を出力しない"] --> As{直前の相手の駒の到達地点と<br>同じ地点か} --> A1[/"到達地点の筋を出力<br>算用数字"/] --> A2[/"到達地点の段を出力<br>新聞・本・雑誌などでは漢数字<br>日本将棋連盟の棋譜記録では算用数字"/] --> A3[/"駒の種類を出力"/] --> Az((基本<br>end)) --> B{持ち駒を打つ<br>置き駒を動かす};
At --> |先手番を明記| Atb[/"先手番の記号を出力<br>例:「☗」「⛊」「▲」「▼」"/] --> As;
At --> |後手番を明記| Atw[/"後手番の記号を出力<br>例:「☖」「⛉」「△」「▽」"/] --> As;
As --> |同じ| As0[/"「同」を出力<br>新聞・本などでは改頁などの都合で<br>「7六同歩」のような表記をする場合あり"/] --> A3;