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
<!doctype html> | |
<title>Hello from Flask</title> | |
<h1>{{project_name}}</h1> | |
<h2>Teams</h2> | |
<table> | |
{% for team in teams %} | |
<tr> | |
<td><a href=/team/{{team.name}}> {{team.name}}</a></td> | |
</tr> |
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
type SymbolTable struct { | |
data *BSTree | |
} | |
//adds or updates node with key "key" | |
func (st *SymbolTable) put(key string, val int) { | |
st.data.root = put(st.data.root, key, val) | |
} | |
//returns node with key "key" |
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
func createFreqTable(arr []string) SymbolTable { | |
st := &SymbolTable{ | |
data: &BSTree{}, | |
} | |
r := regexp.MustCompile("[ .,123456789]") | |
//iterate through words | |
for _, word := range arr { | |
if r.Match([]byte(word)) { | |
//skip punctuation, spaces or numbers | |
continue |
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
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"regexp" | |
"strings" | |
flags "github.com/jessevdk/go-flags" |
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
//A binary search tree has reference to its node | |
type BSTree struct { | |
root *Node | |
} | |
func (btree *BSTree) isEmpty() bool { | |
return btree.root == nil | |
} | |
//search for the key recursively |
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
type Node struct { | |
val int | |
next *Node | |
} | |
type LinkedList struct { | |
head *Node | |
} | |
func (ll *LinkedList) insert(n int) { |
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
func reversePolish(arithmeticExpression string) int { | |
//create regexp for matching against operators | |
r := regexp.MustCompile("[+-/*]") | |
//split input by spaces | |
splitInput := strings.Split(arithmeticExpression, " ") | |
//init Stack | |
s := &Stack{} | |
for _, char := range splitInput { | |
if r.Match([]byte(char)) { |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"regexp" | |
"strconv" | |
"strings" | |
"github.com/Knetic/govaluate" |
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
func quickSort(strings []string) []string { | |
if len(strings) <= 1 { | |
return strings | |
} | |
pivot := strings[0] | |
left := []string{} | |
right := []string{} | |
for i := 1; i < len(strings); i++ { |
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
//helper function for creating input for main func | |
func createFile(numWords int) { | |
if _, err := os.Stat("./generatedStrings.txt"); err != nil { | |
//if file does not exist | |
//create file | |
f, err := os.Create("./generatedStrings.txt") | |
checkErr(err) | |
defer f.Close() | |
for i := 0; i < numWords; i++ { |
NewerOlder