Skip to content

Instantly share code, notes, and snippets.

View oysters76's full-sized avatar
💭
Chilling

Chirath Nissanka oysters76

💭
Chilling
  • Earth
View GitHub Profile
@oysters76
oysters76 / ncd_heatmap.py
Created January 17, 2024 03:47
Heat Map for L-System Comparision via NCD
import numpy as np
import gzip
import matplotlib.pyplot as plt
def runGeneration(query, iterations):
i = 0
g = ""
gen = query
while i < iterations:
g = ""
@oysters76
oysters76 / tree-event.ts
Created December 16, 2023 05:23
Tree Event
type NULL_TNODE = TNode | null;
class TNode{
private parent:NULL_TNODE;
private children:[NULL_TNODE] | null;
private val:string;
constructor(parent:NULL_TNODE, val:string){
this.parent = parent;
this.children = null;
this.val = val;
@oysters76
oysters76 / BuilderPatternDemo.java
Created October 19, 2023 12:03
Simple demo on the builder pattern
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
class Employee{ // <-- entity class
private String fname;
private String lname;
private int age;
private String address;
public Employee(){}
@oysters76
oysters76 / queue_problem.py
Created October 17, 2023 04:30
Queue problem
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
class Node(object):
def __init__(self, name, value, next=None):
self.name = name
self.value = value
self.next = next
def set_next(node):
self.next = node
@oysters76
oysters76 / prob.py
Created August 8, 2022 13:05
A python script that visualizes a normal distribution using pygame
import pygame
import random
import time
# A program that visualizes a normal distribution
# Author: Chirath Nissanka
class VisualizeProbability(object):
def __init__(self):
import numpy as np
from scipy.special import softmax
# encoder representations of four different words
word_1 = np.array([1, 0, 0])
word_2 = np.array([0, 1, 0])
word_3 = np.array([1, 1, 0])
word_4 = np.array([0, 0, 1])
# stack the word embeddings into a single array
@oysters76
oysters76 / tournament-board.py
Created April 9, 2021 17:51
Turtle graphics to draw tournament chart
from turtle import *
#color here is the line color and the fill color
color('black','purple')
ypos = 400
n = 4
#Team names can be declared here
groupa = ['TEAM A', 'TEAM B', 'TEAM C', 'TEAM D']
@oysters76
oysters76 / linsolve.py
Last active April 16, 2021 02:27
Python script to solve linear equations in the terminal
import numpy as np
def isNumber(c):
return c in ['0','1','2','3','4','5','6','7','8','9'];
def parseNumber(n, isNeg):
if (isNeg):
return int(n) * -1;
else:
return int(n)
@oysters76
oysters76 / bagOfWords.py
Created March 27, 2021 16:07
Trival Bag of Words implementation without the Hashing Trick
#Trivial Word Bag implementation using Python
import string
doc1 = "John likes to watch movies. Mary likes movies too.";
doc2 = "Mary also likes to watch football games.";
documents = [doc1, doc2]
def transform(s):
return s.translate(str.maketrans('','',string.punctuation)).lower()