Skip to content

Instantly share code, notes, and snippets.

@mizar
mizar / decimal_rounding_error.ipynb
Last active June 7, 2024 10:33
decimal_rounding_error.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / pmont.ipynb
Last active May 17, 2024 04:42
pmont.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

For the calculation of the sum of integers $A, B$ in $N$-decimal, we divide the $(i-1):k$-digit part into $(i-1):j$-digit and $(j-1):k$-digit parts and consider whether the carry-over occurs for each. $(i \gt j \gt k)$

First, the integers $A, B$ are divided into $(i-1):j$ digits in $N$-decimal, and the values $A_{i-1:j}, B_{i-1:j}$ are added to determine whether carry-forward occurs for the digits above the interval, which are classified into three states as follows.

  • $A_{i-1:j}+B_{i-1:j} \lt N^{i-j}-1$ ; None
  • $A_{i-1:j}+B_{i-1:j} = N^{i-j}-1$ ; Propagate
  • $A_{i-1:j}+B_{i-1:j} \gt N^{i-j}-1$ ; Generate

Example for a decimal number:

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