Skip to content

Instantly share code, notes, and snippets.

@mizar
mizar / sagemath-divmod-issue.ipynb
Last active July 25, 2024 12:28
sagemath-divmod-issue.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 / stlangex_env_standalone.py
Last active September 27, 2024 18:18
StLangEx実行環境 スタンドアロンパーサ版 https://yukicoder.me/problems/no/2908
"""StLang@Lark 実行環境サンプル standalone版"""
### TODO: ここからを本番の問題用の正しいコードに書き換える
PROGRAM = r"""
# サンプルプログラム: 二項係数 nCk の計算 (N > 62 の時は演算オーバーフローする可能性あり)
if N >= K # N < K の時の出力は 0 とする
$0 = 1
$1 = 1
$2 = N
while $1 <= K # for $1 in 1..=K
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mizar
mizar / sorting_network.md
Last active January 2, 2025 13:58
Batcher Odd-Even Mergesort Sorting Network
# Batcher Odd-Even Mergesort Sorting Network Generator
# https://en.wikipedia.org/wiki/Batcher_odd%E2%80%93even_mergesort
# https://en.wikipedia.org/wiki/Sorting_network
gen = lambda N: [
    [
        (i+j, i+j+(1<<k))
        for j in range((1<<k)%(1<<p), N-(1<<k), 2<<k)
        for i in range(min(1<<k, N-j-(1<<k)))
        if (((i+j)^(i+j+(1<<k)))>>(p+1)) == 0
@mizar
mizar / fibonacci.ipynb
Last active February 6, 2025 04:00
fibonacci.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.