Skip to content

Instantly share code, notes, and snippets.

@Bracktus
Bracktus / second.py
Last active April 7, 2024 20:27
Finding the second largest element in a list with n + log2(n) - 2 comparisions
from collections import defaultdict
from random import shuffle
def compare(a, b):
return (a, b) if a > b else (b, a)
def second_largest(nums):
@Bracktus
Bracktus / rounders.rkt
Created January 3, 2022 17:18
A small ball game
#lang sketching
(require racket/list)
(class Player Object
(init-field x y x-vel y-vel attached)
(super-new)
;direction is whether we're rotating clockwise or anti clockwise around the ball.
;either -1 or 1
(define-values (direction) (values 1))
@Bracktus
Bracktus / l-system.py
Created August 18, 2021 13:13
Python L-System
import turtle
import random
class LSystem:
def __init__(self, start, theta, depth):
self.start = start
self.theta = theta
self.depth = depth
self.rules = {}
@Bracktus
Bracktus / MainActivity.java
Created November 3, 2020 13:11
Address to Lat/Long
package com.example.locationfromaddress;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;