This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import numpy as np | |
from gym.wrappers.monitoring import Monitor | |
env = gym.make('CartPole-v0') | |
env = Monitor(env, 'tmp/cart-pole-hill-climb-1', force=True) | |
print("Action space: {0}".format(env.action_space)) | |
print("Observation space: {0}\n\tLow: {1}\n\tHigh: {2}".format( | |
env.observation_space, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cli=/Applications/Karabiner.app/Contents/Library/bin/karabiner | |
$cli set general.dont_remap_internal 1 | |
/bin/echo -n . | |
$cli set remap.commandL2optionL 1 | |
/bin/echo -n . | |
$cli set general.dont_remap_apple_pointing 1 | |
/bin/echo -n . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(a, b): | |
"""Please document me. | |
What am I supposed to do? | |
Rename anything you see fit. | |
Also, I think I have bugs. Please debug me. | |
""" | |
bar = {} | |
for x in a: | |
bar[x] = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can edit this code! | |
// Click here and start typing. | |
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello, 世界") | |
f := who() | |
g := who() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arbitary binary tree (integers) | |
### 1 | |
### 2 3 | |
### 6 4 5 | |
## {1:{"left":2,"right":{3:{"left":4,"right":5}}}} | |
## Goal: -> '{1:{left:2,right:{3:{left:4,right:5}}}}' | |
# 1 | |
# 2 3 | |
## '{1:{left:2,right:3}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check nums for rows, columns and blocks | |
def check(nums): | |
num_dict = {} | |
# assume nums is a list of integers | |
# placeholder for empty is None | |
for num in nums: | |
if not num: | |
continue | |
if num in num_dict: | |
return false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$stack = [] | |
def solution(s) | |
s.each_char do |c| | |
case c | |
when /[0-9]/ | |
$stack.push c | |
puts c | |
when '+' | |
return -1 unless op_nums(lambda { |left, right| left + right }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## SUMMARY | |
# Use Hash($db) to maintain state | |
# Track # open transactions | |
# Memoize modified vars per transaction ($history) | |
# Be naught, use globals (not thread-safe) | |
$db = {} | |
$transactions = 0 | |
$history = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tokenize_query_split query, punctuation | |
punc_regex = /[#{punctuation}\s]+/ | |
tokens = query.split(punc_regex) | |
tokens.each do |token| | |
p token | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz(max): | |
1.upto(max).each do |num| | |
line = '' | |
line << 'Fizz' if num % 3 == 0 | |
line << 'Buzz' if num % 5 == 0 | |
line = num if line.empty? | |
p line | |
end | |
end |