Skip to content

Instantly share code, notes, and snippets.

View Sam-Belliveau's full-sized avatar

Sam Belliveau Sam-Belliveau

View GitHub Profile
import warnings
import matplotlib.pyplot as plt
from typing import Callable, Dict, Iterable, List
warnings.filterwarnings("ignore")
Nodes: List['Node'] = [] # List of every node to make column for
Vars: Dict[str, bool] = {} # Dictionary of every variable and its value
@Sam-Belliveau
Sam-Belliveau / roman_numerals.cpp
Created July 12, 2022 19:18
Constant Expression Generation of Roman Numerals. Every roman numeral generated with this is a string literal, and can be used as such.
/**
* MIT License
*
* Copyright (c) 2022 Sam Belliveau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@Sam-Belliveau
Sam-Belliveau / collatz.hpp
Last active June 19, 2022 00:50
some functions to get the stopping time of a number in the collatz conjecture
#ifndef SAM_B_COLLATZ_CONJECTURE_HEADER
#define SAM_B_COLLATZ_CONJECTURE_HEADER 1
#include <cstdint>
#include <bitset>
#include <bit>
namespace collatz
{
using size_t = std::intmax_t;
@Sam-Belliveau
Sam-Belliveau / wordle_bot.py
Last active January 27, 2022 15:47
It can guess every word in the answer set in <= 5 guesses... guaranteed
#!/bin/python3
################
### WORD SET ###
################
WORDLE_ANSWER_SET = ["cigar", "rebut", "sissy", "humph", "awake", "blush", "focal", "evade", "naval", "serve", "heath", "dwarf", "model", "karma", "stink", "grade", "quiet", "bench", "abate", "feign", "major", "death", "fresh", "crust", "stool", "colon", "abase", "marry", "react", "batty", "pride", "floss", "helix", "croak", "staff", "paper", "unfed", "whelp", "trawl", "outdo", "adobe", "crazy", "sower", "repay", "digit", "crate", "cluck", "spike", "mimic", "pound", "maxim", "linen", "unmet", "flesh", "booby", "forth", "first", "stand", "belly", "ivory", "seedy", "print", "yearn", "drain", "bribe", "stout", "panel", "crass", "flume", "offal", "agree", "error", "swirl", "argue", "bleed", "delta", "flick", "totem", "wooer", "front", "shrub", "parry", "biome", "lapel", "start", "greet", "goner", "golem", "lusty", "loopy", "round", "audit", "lying", "gamma", "labor", "islet", "civic", "forge", "corny", "moult", "basic", "salad", "agate", "spicy",
@Sam-Belliveau
Sam-Belliveau / OptimalSorting.hpp
Last active January 18, 2022 02:59
Sorting Algorithms that are SUPER simple, yet are approximately the speed of std::sort()
/**
* MIT License
*
* Copyright (c) 2022 Sam Belliveau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@Sam-Belliveau
Sam-Belliveau / sort3.hpp
Last active December 7, 2021 15:58
The most efficient way to sort 3 numbers. It uses the exact minimum number of comparisons and assignments. It is hyper efficient with how it moves around the variables to sort the values, only creating a single external swap value. It is implemented as a Binary Insertion Sort, which has ideal comparisons, but not ideal assignments. However becau…
#ifndef SAM_BELLIVEAU_SORT_THREE
#define SAM_BELLIVEAU_SORT_THREE 1
/**
* The most optimal way to sort 3 objects in terms
* of memory usage, assignments, and comparisons.
*
* Can be used as a base function in bigger sorting
* algorithms
*/
@Sam-Belliveau
Sam-Belliveau / primes.c
Last active September 18, 2021 21:35
A program written in english to check for prime numbers
/**
* Copyright 2021, Sam Belliveau
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software
* and associated documentation files (the "Software"),
* to cry when looking at the code gifted to you below.
*
* The code is written as close to the english language
* as possible within the bounds of the c programming language
@Sam-Belliveau
Sam-Belliveau / fast_float_funcs.hpp
Last active June 27, 2021 02:03
C++ file that defines various crude approximations of floating point functions.
/**
* MIT License
*
* Copyright (c) 2021 Sam Belliveau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@Sam-Belliveau
Sam-Belliveau / StuyPulseRCV.py
Last active May 6, 2023 02:29
a simple python script that goes through a CSV file that is created when you use a google form for ranked choice voting.
'''
Copyright (c) 2021 StuyPulse
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@Sam-Belliveau
Sam-Belliveau / hxor.h
Last active February 24, 2021 18:31
Implementation for a home made hashing algorithm that only uses XOR, bitshifts, and multiplication. It is made to be fast, while also usable.
// Copyright (c) 2021 Sam Belliveau. All rights reserved.
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
/**
* These hash functions might seem unnessisarly simple,
* but this hash is made to be as fast as theoretically possible,
* whilst still having good properties.
*
* But when testing this hash, it was shown to be significantly