Skip to content

Instantly share code, notes, and snippets.

@dsetzer
dsetzer / NumberCubeSolver.py
Created September 20, 2024 01:10
Prototype version two for solving 4x4x4 sudoku cube
from enum import Enum
from typing import List, Dict, Tuple
from collections import Counter
import random
import subprocess
class TileType(Enum):
CORNER = 'corner'
EDGE_A = 'edge_a'
EDGE_B = 'edge_b'
@dsetzer
dsetzer / NumberCubeSolver.py
Last active February 19, 2026 05:46
Prototype for solving numbered cube by converting it's state into a standard rubik's revenge state (kociemba notation)
from enum import Enum
from typing import List, Dict
from cube_state import CubeState
from collections import Counter
import subprocess
class TileType(Enum):
CORNER = 'corner'
EDGE_A = 'edge_a'
EDGE_B = 'edge_b'
@dsetzer
dsetzer / CubeState.py
Last active February 19, 2026 05:45
Stores the state for a 4x4x4 number cube.
import random
from collections import defaultdict
class CubeState:
def __init__(self):
self.reset_state()
def reset_state(self):
# Create a default unscrambled state (each face has tiles numbered 1-16)
self.state = [[i for i in range(1, 17)] for _ in range(6)]
@dsetzer
dsetzer / ActuallyFair VX Schema
Last active June 1, 2024 00:26
GraphQL Schema for ActuallyFair (unnecessary third party verifier added to bustabit by new owner Leo)
{
"data": {
"__schema": {
"types": [
{
"name": "Query",
"fields": [
{ "name": "query" },
{ "name": "nodeId" },
{ "name": "node" },
@dsetzer
dsetzer / prob_using_coefficients.py
Last active August 17, 2023 16:16
Calculating probabilities with coefficients calculated from simulations
import hmac
import hashlib
import binascii
import math
from collections import Counter
from scipy.optimize import curve_fit
import numpy as np
# Number of games to simulate (10 million)
num_games_to_simulate = 10_000_000
@dsetzer
dsetzer / run-length-compression.js
Created May 24, 2023 02:50
RunLength Encoding (RLE) text compression using Unicode symbols
/**
* Run-Length Encoding (RLE) text compression using Unicode symbols.
*
* This algorithm compresses text by counting the number of consecutive identical
* characters in the input string and representing them in a compact format within
* the compressed string using Unicode characters. The encoded and decoded parts
* are separated by a Unicode private-use character, U+FFF0.
*
* @param {string} inputText - The text to be compressed.
* @returns {string} - The compressed text.
@dsetzer
dsetzer / mapRange.js
Created April 29, 2023 05:43
Map a value from one range to another range
/**
* Map a value from one range to another
* @param {number} value - The value to map
* @param {number} inMin - The minimum value of the input range
* @param {number} inMax - The maximum value of the input range
* @param {number} outMin - The minimum value of the output range
* @param {number} outMax - The maximum value of the output range
* @returns {number} The mapped value
*/
const mapRange = (value, inMin, inMax, outMin, outMax) => {
@dsetzer
dsetzer / README.md
Created January 26, 2023 20:50 — forked from fahadysf/README.md
A multiprocess task broker which accepts and provides status reports for tasks using JSON REST API calls.

Multiprocess Task Broker with REST API

This gist shows and example or an asynchronous multiprocess task broker which can take job requests and report on running jobs via a minimal REST API.

Adapted from https://gist.github.com/nitaku/10d0662536f37a087e1b

All of the caveats from the original author still apply.

@dsetzer
dsetzer / cumulativeProbs.js
Created July 29, 2022 13:02
Probability functions (codex generated)
// Cumulative Geometric Probability
function getGeoProb(p, n) {
return (1 - Math.pow(p, n)) / (1 - p);
}
// Cumulative Hypergeometric Probability
function getHyperProb(N, n, K, k) {
return getCombin(K, k) * getCombin(N - K, n - k) / getCombin(N, n);
}
@dsetzer
dsetzer / StreakSegment.js
Last active June 18, 2023 16:14
Function to split up an array into separate groups of W/L streaks.
/**
* Takes in an array of numbers and returns an array of streaks of numbers.
* @param {Array} results - An array of numbers.
* @param {Number} multiplier - The number that determines the streak.
* @returns {Array} - An array of streaks of numbers.
*/
function getStreaks(results, multiplier) {
let streaks = new Array();
let streak = new Array();
for (let i = 0; i < results.length; i++) {