Skip to content

Instantly share code, notes, and snippets.

View cocosbeans's full-sized avatar
♀️

Blair Myhre cocosbeans

♀️
  • Huntsville, TX, USA
  • 18:13 (UTC -06:00)
View GitHub Profile
@cocosbeans
cocosbeans / custom_config_loader.py
Last active October 25, 2024 14:59
A simple, custom config format loader
# This program parses a very simple config file format into a dict (from a file path).
# Doesn't matter what the extension is, that doesn't matter in this code.
# But if the file doesn't exist, it returns None.
# No credit required, but would be appreciated :P
# (Written by Blair Myhre for SYWFETCH -- 2024)
#
# The format is as follows:
# - Each value is separated by an equals sign =
# - Comments can be written by starting a line with #
# - Comments will be ignored if there is any character preceding the #
Number 999998 (iterations: 258) has less iterations than 837799 (iterations: 524).
Number 999999 (iterations: 258) has less iterations than 837799 (iterations: 524).
The number with the most iterations was 837799 with 524 iterations.
Operation took 1017.723977081s.
use std::time::Instant;
fn collatz_step(n: u64) -> u64 {
if n % 2 == 0 { n / 2 }
else { 3 * n + 1 }
}
fn collatz(n: &u64) -> Vec<u64> {
let mut x: u64 = n.clone();
let mut nums = vec![0; 0];
#![allow(dead_code)]
fn collatz_step(n: u64) -> u64 {
if n % 2 == 0 { n / 2 }
else { 3 * n + 1 }
}
fn collatz(n: &u64) -> Vec<u64> {
let mut nums = vec![0; 0];
let mut x: u64 = n.clone();
@cocosbeans
cocosbeans / collatz.rs
Last active October 4, 2024 13:40
rust function for the collatz conjecture
fn main() {
let mut x: u64 = 100; //First number
let mut c: u64 = 0; //Counts how many times the equation was evaluated
let mut nums = vec![0; 0]; //Output of each number
let s: u64 = x; //First number, but invariable
while x >= 2 {
c += 1;
nums.push(x);
x = collatz(x);
@cocosbeans
cocosbeans / lisbon.js
Last active September 30, 2024 15:32
const Tokens = {
'$': "%DOLLAR",
'(': "%PARENTHESIS_OPEN",
')': "%PARENTHESIS_CLOSE",
'%': "%PERCENT",
'#': "%POUND",
"'": "%QUOTE",
' ': "%SPACE"
}
@cocosbeans
cocosbeans / matrix.js
Last active September 4, 2024 17:32
A class for a matrix, made to behave like an Array
// class Matrix, created by cocosbeans
//
// Require it: const { Matrix } = require('./matrix.js');
// Use it: const matrix = new Matrix(x, y);
//
// Matrix.pointer: a two-item array containing [row, col]
// Matrix.matrix: the matrix defined by the constructor
//
// constructor(width, height)
// Define a matrix with a width and height.
;;This code is the functionality behind the endless waves mode of Kill The Parasites.
;;To be used with https://www.curseforge.com/minecraft/mc-mods/clojure-command-language
;;For Bali's Kill The Parasites modpack https://www.curseforge.com/minecraft/modpacks/kill-the-parasites
;;Function 'lib/exec' is from the CurseForge mod on line 2.
;;WORK IN PROGRESS!
(ns infinite.core
(:use clojure.test )
(:require [clojure.string :as string] ))
const TokenHandler = require('./token/token-handler.js')
const token = new TokenHandler()
class Parse {
parse(code) {
let x = ""
for (this.i = 0; this.i < code.length; this.i++) {
if (code[this.i] === " ") x += " SPACE" //Special exception 1
if (code[this.i] === "\n") x += " NEWLN" //Special exception 2
class Token {
constructor() {
this.token = require('./token.json')
this.types = require('./types.json')
this.list_string = this.types["STRING"]
this.list_symbol = this.types["SYMBOL"]
}
checkType(object = '') {