Skip to content

Instantly share code, notes, and snippets.

@AMathMonkey
AMathMonkey / impostor_stats.jl
Created December 5, 2020 05:35
Julia script that simulates multiple games of Among Us to count the number of players who were never the impostor in any of those games, then repeats this multiple times to find the average chance of there being a player who was never the impostor
#=
Script that simulates multiple games of Among Us
to count the number of players who were never the impostor in any of those games,
then repeats this multiple times to find the average chance
of there being a player who was never the impostor
=#
print("How many simulations? ")
nsimulations = parse(Int, readline())
## array of number of players that were never impostor for each simulation
@AMathMonkey
AMathMonkey / SudokuHelper.py
Last active July 1, 2024 04:23
Solves medium-difficulty sudoku puzzles but not hard ones for some reason, but it will narrow down the possibilities of most squares pretty well
import numpy as np
board = np.empty(shape=(9, 9), dtype=set)
def isknown(cell):
return len(cell) == 1
def construct_board():
with open("board.txt", "r") as f:
for li, line in enumerate(f):
@AMathMonkey
AMathMonkey / BARTimeCalcHaskell.hs
Last active November 4, 2020 03:32
The executable for this is 11 MB, ugh, and I spent hours writing this code and it's all for nothing (except practice)
import Data.Char (digitToInt, isNumber, toUpper)
import Text.Printf (printf)
import TimeLibrary (Time (..), addTimes, minTime)
tracks :: [String]
tracks =
[ "Coventry Cove",
"Mount Mayhem",
"Inferno Isle",
"Sunset Sands",
@AMathMonkey
AMathMonkey / BARTimeCalcDart.dart
Created November 2, 2020 07:08
This one was fun to write, but the exe generated by it is 5 MB, so D still wins the exe size war by a lot
import 'dart:io';
String padInt2(int a) {
return a.toString().padLeft(2, '0');
}
void main() async {
const tracks = [
"Coventry Cove",
"Mount Mayhem",
@AMathMonkey
AMathMonkey / BARTimeCalcKotlin.kt
Created November 2, 2020 05:33
I'm making the same app in tons of different languages as practice, this one went poorly, not a Kotlin fan
package BARTimeCalcKotlin
import java.io.File
val tracks = arrayOf("Coventry Cove", "Mount Mayhem", "Inferno Isle", "Sunset Sands", "Metro Madness", "Wicked Woods")
val greeting =
"""
BAR! Bonus Circuit IGT Calculator by AMathMonkey
Input times in the format MSShh where M is minutes, SS is seconds and hh is hundredths
Enter 'u' to undo
import std.stdio : File, write, writef, writeln, writefln, readln;
import std.typecons : Nullable, nullable;
import std.conv : to, ConvException;
import std.format : format;
import std.string : chomp, toLower;
const string[] tracks = [
"Coventry Cove", "Mount Mayhem", "Inferno Isle", "Sunset Sands",
"Metro Madness", "Wicked Woods",
];
tracks = {
"Coventry Cove", "Mount Mayhem", "Inferno Isle", "Sunset Sands",
"Metro Madness", "Wicked Woods"
}
times = {}
stdout = io.output()
minutes, seconds, hundredths, i = 0, 0, 0, 1
print([[
@AMathMonkey
AMathMonkey / BARTimeCalcHaxe.hx
Last active November 2, 2020 07:12
Was easier to write than the D version and produced a pretty small 600 KB exe, but that's still almost twice the size of the D version
import haxe.io.Bytes;
import Sys.*;
import sys.io.File as File;
class BARTimeCalculator {
static final tracks = [
"Coventry Cove",
"Mount Mayhem",
"Inferno Isle",
"Sunset Sands",
@AMathMonkey
AMathMonkey / BARTimeCalc.py
Created July 14, 2019 23:54
Beetle Adventure Racing total in-game time calculator, to quickly determine that value for submissions on speedrun.com/bar
import os
tracks = ("Coventry Cove", "Mount Mayhem", "Inferno Isle", "Sunset Sands", "Metro Madness", "Wicked Woods")
times = []
minutes = seconds = hundredths = i = 0
print(
"""BAR! Bonus Circuit IGT Calculator by AMathMonkey
Input times in the format MSShh where M is minutes, SS is seconds and hh is hundredths
Enter 'u' to undo""")
@AMathMonkey
AMathMonkey / BARSpeedClientPython3.py
Last active July 15, 2019 12:24
BAR! Speed Display - Server For PJ64d and BizHawk, Client for Python3
import socket
import matplotlib.pyplot as plt
from numpy import arange
MPH_CHOICE = False # Change to True for mph not km/h
freq = 0.05 # sampling rate of the speed value
cycles = 300 # number of points to plot before stopping
plt.xlim(0, freq * cycles) # make room in the x dimension for all the points