Skip to content

Instantly share code, notes, and snippets.

@Eatkin
Eatkin / sudoku-solver.py
Created May 6, 2023 14:24
Sudoku Brute Forcer. Uses recursion to test every possible valid combination of numbers until a solution is found. Can solve human-unsolvable sudokus.
'''
Example usage:
grid = [
[7,0,0, 0,0,9, 0,0,0],
[0,0,0, 6,0,0, 0,4,0],
[0,0,2, 0,0,0, 0,0,0],
[0,0,0, 0,0,0, 4,0,0],
[0,5,0, 0,4,6, 0,0,0],
[0,0,0, 0,0,0, 0,0,0],
@Eatkin
Eatkin / linked-list.py
Created April 24, 2023 08:10
Linked list implementation. Includes insert at position, remove at position, get position and reverse methods. Also includes unit tests.
import unittest
# Create the node class
class Node(object):
def __init__(self, d, n=None):
self.data = d
self.next_node = n
def get_next(self):
return self.next_node
@Eatkin
Eatkin / hello-world-but-stupid.js
Created April 19, 2023 08:16
A raelly 🅱️ad implementation of "hello world"
const greet = function() {
let greeting = "h";
greeting += "e".repeat(2);
greeting = greeting.slice(0, 2);
greeting += "l".repeat(5 + Math.ceil(Math.random() * 10));
while (greeting !== "hell")
greeting = greeting.slice(0, -1);
greeting += "o";
for (let i = 0; i < 7; i++)
greeting += " ".repeat(100 + Math.floor(Math.random() * 10));
@Eatkin
Eatkin / colorful-numbers.py
Created April 19, 2023 08:08
Algorithm to return if a number is colorful
'''A number is colorful if all products of the subsets of individual digits are unique
e.g. 263 is colorful:
2 * 6 * 3 = 36
2 * 6 = 12
6 * 3 = 18
'''
def is_colorful(num):
# Account for negatives (results will be the same)
num = abs(num)
@Eatkin
Eatkin / fizz-buzz-but-oop.py
Created April 19, 2023 08:01
Fizz Buzz but it unnecessarily uses OOP
class FizzBuzz(object):
def __init__(self, n):
self.size = n
# Define a dictionary containing the fizz buzzes
self.d = {3: "Fizz",
5: "Buzz"}
def get_fizzbuzz_sequence(self):
ls = []
for i in range(1, self.size + 1):
@Eatkin
Eatkin / greeting-but-horribly-inefficient.js
Last active April 19, 2023 08:16
A horribly inefficient implementation of "hello world!".
const greet = function() {
let greeting = "";
while (greeting !== "hello world!") {
greeting = "h".repeat(Math.ceil(Math.random() * 5));
greeting += "e".repeat(Math.ceil(Math.random() * 5));
greeting += "l".repeat(Math.ceil(Math.random() * 5));
greeting += "o".repeat(Math.ceil(Math.random() * 5));
greeting += " ".repeat(Math.ceil(Math.random() * 5));
greeting += "w".repeat(Math.ceil(Math.random() * 5));
greeting += "o".repeat(Math.ceil(Math.random() * 5));