Instantly share code, notes, and snippets.

# Jon Bodnerjonbodner

• Sort options
Created Jul 1, 2014
First non-repeated character in a string in Go
View firstNonRepeat.go
 package main import "fmt" func firstNonRepeatChar(s string) rune { useMap := make(map[rune]bool) for _, v := range s { _, ok := useMap[v] useMap[v] = ok }
Created Jul 1, 2014
Very silly FizzBuzz in Go
View fizzbuzz.go
 package main import "fmt" type data struct { i int s string } func (d data) String() string {
Created Jul 5, 2014
Simple implementation to demonstrate the Monty Hall Problem (http://en.wikipedia.org/wiki/Monty_Hall_problem)
View monty_hall.go
 package main import ( "fmt" "math/rand" "os" "strconv" "time" )
Created Jul 14, 2014
Solver for the 6-point Magic Star Problem
View star_solve.go
 package main import ( "fmt" ) type ValSet struct { one, two, three, four *int }
Last active Aug 29, 2015
FizzBuzz for Go with no conditionals.
View fizzbuzz_no_cond.go
 package main import "fmt" type fber func(int)string func fizzer(i int) string { return "fizz" }
Created May 1, 2012
Generic Y Combinator in Java
View YFact.java
 //based on code from http://www.arcfn.com/2009/03/y-combinator-in-arc-and-java.html class YFact { // T function returning a T // T -> T public static interface Func { T apply(T n); } // Higher-order function returning a T function
Created May 3, 2012
Y Combinator in Go
View YFact.go
 package main import "fmt" //based on code from http://www.arcfn.com/2009/03/y-combinator-in-arc-and-java.html type Func func (interface{}) interface{} type FuncToFunc func (Func) Func
Created May 7, 2012
Even-Odd Partition in Go
View even_first.go
 package main import "fmt" import "math/rand" import "time" func main() { rand.Seed(time.Now().UnixNano()) vals := rand.Perm(10) fmt.Println(vals)
Created May 13, 2012
Calculate Partition in Go
View partition.go
 package main import "fmt" import "sort" type EMPTY struct {} var PRESENT EMPTY = EMPTY{} func partition(val int) []string {
Created May 25, 2012
View Streaming_Knapsack.go
 package main import ( "fmt" "math/rand" ) /* A famous problem of computer science is the knapsack problem, in which you are to find a combination of items from a population that sums to a given target, often with some kind of constraint such as maximizing the value of the items. In today’s problem we want to find the first possible combination
You can’t perform that action at this time.