Skip to content

Instantly share code, notes, and snippets.

View angch's full-sized avatar

Ang Chin Han angch

  • Kuala Lumpur, Malaysia
View GitHub Profile
terms = [None] * 1000001
maxterms = 0
maxtermsNum = 0
for i in range(1,1000001):
c = i
count = 1
while c > 1:
if c % 2 == 0:
package main
import "fmt"
func main() {
terms := make([]int16, 1000001)
maxterms := int16(0)
maxtermsNum := 0
for i := range terms {
@angch
angch / pokerbot.go
Last active February 24, 2016 15:47
Naive pokerbot for http://mitpokerbots.com/ (quick hack, too lazy to fix this properly)
// quick hack, too lazy to fix this properly.
// Yes, I know scoring logic coded here is wrong for the following format:
// "make the best hand using exactly two of the dealt cards and three community cards."
package main
import (
"bufio"
"fmt"
"log"
// https://forum.lowyat.net/topic/3852732
// Quick and Dirty hack
// angch's go kata
// Original idea was to scale up and use Go channels, but we can't do
// priority queue that way.
package main
// https://forum.lowyat.net/topic/3852732
// Quick and Dirty hack
// angch's go kata
// Original idea was to scale up and use Go channels, but we can't do
// priority queue that way.
package main
@angch
angch / knapsack.go
Last active February 21, 2018 02:14
Code kata. Go. Knapsack problem, "dynamic programming". https://forum.lowyat.net/topic/3765924/+0
// https://forum.lowyat.net/topic/3765924/+0
package main
import "fmt"
/*
1. A vase that weights 3 pounds and is worth 50 dollars.
2. A silver nugget that weights 6 pounds and is worth 30 dollars.
3. A painting that weights 4 pounds and is worth 40 dollars.
4. A mirror that weights 5 pounds and is worth 10 dollars.
@angch
angch / asyncfetch.go
Last active September 17, 2015 10:09
quickie rewrite of Python's asyncio http://www.giantflyingsaucer.com/blog/?p=5557 in Go
// quickie rewrite of http://www.giantflyingsaucer.com/blog/?p=5557 in Go
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func fetch_page(url string) chan bool {
@angch
angch / water2.go
Created August 21, 2015 14:35
"Optimized" Water Disruption solution
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"math/rand"
"os"
@angch
angch / tower2.go
Created August 21, 2015 14:28
"Optimized" Cellular Tower solution.
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"math/rand"
"os"
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"regexp"
"strconv"
)