This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem statement | |
You are given positive integers M,N,K | |
Define the set of matrices X of shape (M,N) and integer entries i between 1\leq i\leq K. | |
Find the number of "effectively different" matrices in X where two matrices a and b are effectively the same if a's rows and/or columns can be permuted s.t. a == b. | |
Short statement on how far classic algorithms fall from solving this problem | |
Symmetry & Group theory | |
Groups are useful for analyzing symmetry | |
Give group definition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <vector> | |
#include <iostream> | |
using i64 = long long int; | |
// first implementation | |
// template<typename T, int Size, int... Sizes> | |
// struct mdarray { | |
// template <typename... Is> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BB Note: Because I now store images in PNG format I could just compare PNG byte buffers. | |
# | |
# so... this code is not necessary anymore. | |
from random import randint,shuffle | |
import hashlib | |
import shutil | |
import torchvision as tv | |
import torch as th |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# combined_algorithm.py | |
# A single, parameterized, algorithm solves two different enumeration problems: number partitions and k sized subsets of multisets. | |
def fill_from_right(k, array, capacities, get_value): | |
for i in range(len(array)): | |
assert (array[i] == 0) | |
while array[i] < capacities[i] and k > 0: | |
array[i] += 1 | |
k -= get_value(i) | |
if k == 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partition_enumeration(n): | |
counts = [0]*(n+1) # n+1 to allow 1 based indexing | |
counts[1] = n | |
first_non_empty_slot = 1 | |
while counts[n] == 0: | |
yield [(length+1, count) for length, count in enumerate(counts[1:]) if count != 0] | |
# starting from slot i=first_non_empty_slot move enough dots to slot 1 | |
# to create a dot at slot i+1 using dots at slot 1 | |
for i in range(first_non_empty_slot, n+1): | |
if counts[i] != 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disorderly Escape | |
================= | |
Oh no! You've managed to free the bunny prisoners and escape Commander Lambdas exploding space station, but her team of elite starfighters has flanked your ship. If you dont jump to hyperspace, and fast, youll be shot out of the sky! | |
Problem is, to avoid detection by galactic law enforcement, Commander Lambda planted her space station in the middle of a quasar quantum flux field. In order to make the jump to hyperspace, you need to know the configuration of celestial bodies in the quadrant you plan to jump through. In order to do *that*, you need to figure out how many configurations each quadrant could possibly have, so that you can pick the optimal quadrant through which youll make your jump. | |
There's something important to note about quasar quantum flux fields' configurations: when drawn on a star grid, configurations are considered equivalent by grouping rather than by order. That is, for a given set of configurations, if you exchange the position of any two colum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChainProcessor { | |
var arg = ''; | |
var didUpdateArg = false; | |
bool isComputing = false; | |
void _computation() { | |
// do stuff | |
} | |
void chain() async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(x): | |
if x % 2 == 0: | |
return x // 2 | |
return 3 * x + 1 | |
def check(): | |
n = 1 | |
while 1 > 0: | |
n = n + 1 | |
a = n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
Config* config = new Config; | |
Programs* programs = new Programs; | |
Renderer* renderer = new Renderer; | |
Window* window = new Window; | |
while (true) { | |
if (user_config_changed()) { | |
logger.log("Updating state."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
Config* config = new Config; | |
Programs* programs = new Programs; | |
Renderer* renderer = new Renderer; | |
Window* window = new Window; | |
while (true) { | |
if (user_config_changed()) { | |
logger.log("Updating state."); |
NewerOlder