Skip to content

Instantly share code, notes, and snippets.

View johnny-morrice's full-sized avatar

John Morrice johnny-morrice

View GitHub Profile
from unittest import TestCase, main
def valid_parentheses(string):
x = 0
for char in string:
if char == '(':
x += 1
elif char == ')':
if x == 0:
return False
@johnny-morrice
johnny-morrice / buffpool.go
Created February 19, 2016 09:30
Use buffered channel to limit number of goroutines spawned
type goPool struct {
hold sync.WaitGroup
work chan func()
ready chan bool
}
func newGoPool(jobs uint) *goPool {
pool := &goPool{}
pool.ready = make(chan bool, jobs)
pool.work = make(chan func())