Skip to content

Instantly share code, notes, and snippets.

@mizar
mizar / pmont.ipynb
Last active May 17, 2024 04:42
pmont.ipynb
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 / qrcode.ps1
Last active November 16, 2023 16:36
QR Code display with Powershell
# QR Code display with Powershell
# License: MIT
# usage example:
# powershell.exe -Exec bypass -File qrcode.ps1 -Payload https://qiita.com/ -EccLevel Q
# powershell.exe -Exec bypass -File qrcode.ps1 -Payload "日本語SJIS" -EccLevel Q -Encoding SJIS
# powershell.exe -Exec bypass -File qrcode.ps1 -Payload "日本語UTF8" -EccLevel Q -Encoding UTF-8
Param(
# String to be embedded in QR Code
[String]$Payload = "https://github.com/",
@mizar
mizar / prime_scan.gp
Last active January 9, 2023 07:02
整数環FFT用素数探索 (PARI/GP script)
hex(n) =
{
return(if(n < 0, Strprintf("-0x%x", -n), Strprintf("0x%x", n)));
};
ban(n) =
{
local(b, c, v);
c = round(n);
v = "";
while(c != 0,
@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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / frame.svg
Created May 23, 2019 21:04
Shogi Piece Texture Guide-Frame https://i.imgur.com/yIn1T5b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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