Skip to content

Instantly share code, notes, and snippets.

Kevin Chen kevchn

Block or report user

Report or block kevchn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kevchn /
Last active Apr 10, 2018
Brute-Force Random Policy Search on Cartpole
import gym
import numpy as np
env = gym.make('CartPole-v0')
def run_episode(params):
total_reward = 0
observation = env.reset()
while True:
action = 0 if (params @ observation) < 0 else 1
kevchn /
Created Sep 8, 2017
Determine if a LinkedList is a Palindrome Recursively
def isLinkedListPalindromeRecursive(ll):
Recursively (recurse halfway (left), then pass down the next node (right) when recursing back through the stack)
This is the same as creating a stack in the first half and iterating through the next and popping
time: o(n)
space: o(n)
where n is the # of nodes in the list
return recurse(ll.head, lengthOfList(ll), [None])
You can’t perform that action at this time.