Skip to content

Instantly share code, notes, and snippets.

@unworthyEnzyme
unworthyEnzyme / solver.py
Created December 28, 2024 13:42
sudoku solver
import os
from typing import List, Tuple
import itertools
possibilities = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
def solve(board: List[List[int]]) -> List[List[int]] | None:
if is_solved(board):
@unworthyEnzyme
unworthyEnzyme / index.html
Created November 7, 2024 09:11
Websocket presentation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
#messages {
display: flex;
flex-direction: column;
@unworthyEnzyme
unworthyEnzyme / EightPuzzleAnalysis.java
Created November 2, 2024 16:38
8-puzzle Problem with A* and RBFS
import java.util.*;
import java.time.Instant;
import java.time.Duration;
public class EightPuzzleAnalysis {
public static void main(String[] args) {
int[][] initialState = {
{ 7, 2, 4 },
{ 5, 0, 6 },
{ 8, 3, 1 }
@unworthyEnzyme
unworthyEnzyme / multi_methods.rb
Last active January 2, 2025 09:22
Multi-methods/multiple dispatch implemented in ruby
class Type
attr_accessor :name
attr_accessor :supertype
def initialize(name, supertype = nil)
@name = name
@supertype = supertype
end
def is?(type)
package org.example;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.ForkJoinPool;
public class ParallelMergeSort {
private static final int THRESHOLD = 100;
private static class MergeSortTask extends RecursiveAction {
private final Comparable[] array;
@unworthyEnzyme
unworthyEnzyme / client.py
Last active April 26, 2024 08:55
tcp broadcast
import socket
import sys
import threading
from message import Message
# Function to handle receiving messages from the server
def receive_messages(client_socket):
while True:
try:
const EventEmitter = require("events");
function fetchUserName(id) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(`user${id}`), 1000);
});
}
function fetchUserAge(id) {
return new Promise((resolve, reject) => {
@unworthyEnzyme
unworthyEnzyme / quicksort.cpp
Created November 24, 2022 15:48
quicksort in c++
#include <vector>
auto partition(std::vector<int>& arr, int start, int end) -> int {
auto pivotIndex = end;
for (int i = start; i < pivotIndex; i++) {
if (arr[i] > arr[pivotIndex]) {
auto temp = arr[i];
arr[i] = arr[pivotIndex];
arr[pivotIndex] = temp;
pivotIndex = i;