Skip to content

Instantly share code, notes, and snippets.

View krischal111's full-sized avatar

Krischal Khanal krischal111

View GitHub Profile
@krischal111
krischal111 / just-intonation-in-cents.py
Last active April 21, 2026 19:41
A code that gives just intonation ratios in cents, which may be used for tuning purposes.
from math import log2
just_intonation_ratios = {
# Suddha swara
"\n## Suddha swara": {},
"Sa" : {1.0},
"Re": {9/8, 10/9}, # Two fifths = 9/8
"Ga": {5/4},
"Ma": {4/3},
"Pa": {3/2},
@krischal111
krischal111 / popcount.rs
Created October 5, 2024 18:34
Count Set Bits in Rust
// Brian Kernighan's Algorithm to count set bits
// Takes only as many iterations as the number of set bits
fn popcount(mut num: i32) -> u32 {
let mut n = 0;
while (num != 0) {
n += 1;
num = num & (num - 1);
}