Skip to content

Instantly share code, notes, and snippets.

View RandyMcMillan's full-sized avatar
🛰️
Those who know - do not speak of it.

@RandyMcMillan RandyMcMillan

🛰️
Those who know - do not speak of it.
View GitHub Profile
@RandyMcMillan
RandyMcMillan / byzantine_quorum.rs
Last active December 3, 2025 15:12 — forked from rust-play/playground.rs
byzantine_quorum.rs
use std::collections::HashMap;
use rand::{seq::SliceRandom, thread_rng};
// --- BQS Constants ---
// Maximum number of Byzantine faults (f or b) the system can tolerate.
const F: u32 = 4;
// The required supermajority count for a client to accept a value as correct.
// A value is only considered valid if F + 1 servers report it, allowing the
// client to mask 'F' colluding malicious responses.
@RandyMcMillan
RandyMcMillan / minimal_crust.rs
Last active December 2, 2025 16:35 — forked from rust-play/playground.rs
minimal_crust.rs
// main.rs - A minimal Crust program with tests
//
#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), no_main)]
extern crate libc;
#[cfg(not(test))]
use core::panic::PanicInfo;
@RandyMcMillan
RandyMcMillan / lojban_gemini.rs
Last active November 30, 2025 20:46 — forked from rust-play/playground.rs
lojban_gemini.rs
// --- Dependencies ---
// This simple example relies only on standard library features.
use std::error::Error;
use std::fmt;
// --- Error Handling ---
/// A simple custom error type for parsing issues.
#[derive(Debug)]
struct ParseError {
@RandyMcMillan
RandyMcMillan / divisibility.rs
Last active November 25, 2025 15:45 — forked from rust-play/playground.rs
divisibility.rs
// The core concept is that for a number 'n', if 'n % d == 0', then 'n' is divisible by 'd'.
// Divisibility tests rely on properties of the digits.
/// 🔢 Divisibility Tests Module
mod divisibility_tests {
// Helper function to get the sum of digits
pub fn sum_digits(n: u64) -> u64 {
let mut sum = 0;
let mut num = n;
while num > 0 {
@RandyMcMillan
RandyMcMillan / gamma_1_2_squared.rs
Last active November 19, 2025 19:14 — forked from rust-play/playground.rs
gamma_1_2_squared.rs
// Verbose Script: Corrected Floating-Point Comparison
fn main() {
// ----------------------------------------------------
// 1. Define Constants
// ----------------------------------------------------
const PI: f64 = std::f64::consts::PI;
let gamma_one_half: f64 = PI.sqrt();
@RandyMcMillan
RandyMcMillan / grind.py
Created November 19, 2025 00:39 — forked from djkazic/grind.py
import secrets
from statistics import mean
# secp256k1 parameters
p = 2**256 - 2**32 - 977
b = 7 # y^2 = x^3 + 7
def is_quadratic_residue(n):
"""Return True if n is a quadratic residue mod p (including 0)."""
if n == 0:
import secrets
# secp256k1 parameters
p = 2**256 - 2**32 - 977
a = 0
b = 7
def random_256bit_int():
# random 32-byte string interpreted as big-endian integer
return int.from_bytes(secrets.token_bytes(32), "big")
#!/usr/bin/env python3
import sys
import secrets
from statistics import mean
p = 2**256 - 2**32 - 977
b = 7 # y^2 = x^3 + 7
def is_quadratic_residue(n):
return n == 0 or pow(n, (p - 1) // 2, p) == 1
@RandyMcMillan
RandyMcMillan / 3D-Ulam-Spiral.rs
Last active November 16, 2025 03:01 — forked from rust-play/playground.rs
3D-Ulam-Spiral.rs
// a 3D Ulam Spiral
// projected onto a 2D grid,
// marking primes with their Z-index.
/// Generates a boolean vector where `is_prime[i]` is true if `i` is a prime number (Sieve of Eratosthenes).
fn sieve_of_eratosthenes(max_value: usize) -> Vec<bool> {
if max_value < 2 { return vec![]; }
let mut is_prime = vec![true; max_value + 1];
is_prime[0] = false;
is_prime[1] = false;
@RandyMcMillan
RandyMcMillan / cantor_diagonal.rs
Last active November 15, 2025 11:56 — forked from rust-play/playground.rs
cantor_diagonal.rs
use std::fmt::{self, Display};
// Define a type alias for a binary sequence (a vector of 0s and 1s)
type BinarySequence = Vec<u8>;
/// Attempts to demonstrate Cantor's Diagonal Argument.
///
/// It generates a list of sample binary sequences and constructs a new
/// diagonal sequence that is guaranteed to not be in the list.
fn main() {