Skip to content

Instantly share code, notes, and snippets.

View ispapadakis's full-sized avatar

Yanni Papadakis ispapadakis

  • Papadakis Consulting LLC
  • Skillman, NJ
View GitHub Profile
@ispapadakis
ispapadakis / pid_cartpole.py
Created July 15, 2022 17:34 — forked from HenryJia/pid_cartpole.py
Solving OpenAI's Cartpole with a very simple PID controller in 35 lines
import numpy as np
import gym
def sigmoid(x):
return 1.0 / (1.0 + np.exp(-x))
env = gym.make('CartPole-v1')
desired_state = np.array([0, 0, 0, 0])
desired_mask = np.array([0, 0, 1, 0])
@ispapadakis
ispapadakis / biconnected.py
Last active February 22, 2018 16:30
Biconnected Component Analysis of Undirected Graph (i.e., Bridges, Articulation Points) with Condensed Tree
class Graph(object):
'''
Undirected Graph
INPUT:
Node Count: Int
Edges: List in format [source, end]
'''
def __init__(self,n,edges):
self.nodeCount = n
self.label = list(range(n))
@ispapadakis
ispapadakis / disjointSet.py
Last active February 16, 2018 23:21 — forked from cocodrips/union_find.py
Union Find in Python with Path Compression and Balancing
'''
Implement a Disjoint Set Data Structure Using Path Compression and Balancing
'''
class disjointSet:
def __init__(self, n):
self.parent = list(range(n))
self.rank = [0] * n
def find(self, element):
@ispapadakis
ispapadakis / binarySearchTree.py
Last active April 11, 2018 13:16 — forked from jakemmarsh/binarySearchTree.py
a simple implementation of a Binary Search Tree in Python
# Extended the class to address previous comments: a) redundant inserts, b) delete method
class Node:
def __init__(self, val):
self.val = val
self.parent = None
self.__left = None
self.__right = None
self.code = 3