Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ryanslade/project-euler
base: e181951f7d
...
head fork: ryanslade/project-euler
compare: 34c62dd3b4
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 30, 2012
@ryanslade Ignore .pyc files a19eff3
Commits on Oct 07, 2012
@ryanslade Completed 15 and 31 34c62dd
Showing with 81 additions and 7 deletions.
  1. +1 −1  .gitignore
  2. +2 −2 10.go
  3. +4 −4 14.go
  4. +27 −0 15.go
  5. +23 −0 15_test.go
  6. +24 −0 31.go
View
2  .gitignore
@@ -1,3 +1,3 @@
*.exe
*.class
-.pyc
+*.pyc
View
4 10.go
@@ -1,11 +1,11 @@
-package main
+package ten
import (
"./euler"
"fmt"
)
-func main() {
+func calculate() {
total := uint64(0)
for i := uint64(1); i < 2000001; i++ {
View
8 14.go
@@ -1,21 +1,21 @@
-package main
+package fourteen
import "fmt"
-func main() {
+func solve() {
var longest, i uint = 0, 1
for ; i < 1000000; i++ {
count := calculateChain(i)
if count > longest {
longest = count
- fmt.Println(count)
+ fmt.Printf("%v: %v \n", i, count);
}
}
}
func calculateChain(n uint) uint {
- var count uint = 1
+ count := uint(1)
for ; n != 1; count++ {
if (n % 2) == 0 {
n = n / 2
View
27 15.go
@@ -0,0 +1,27 @@
+package main
+
+import (
+ "fmt"
+)
+
+func solve(size int64) int64 {
+ return getRoutes(size, 0, 0, 0)
+}
+
+func getRoutes(size, x, y, accu int64) int64 {
+ if x == size && y == size {
+ return accu + 1
+ }
+
+ if x > size || y > size {
+ return accu
+ }
+
+ return getRoutes(size, x+1, y, accu) + getRoutes(size, x, y+1, accu)
+}
+
+func main() {
+ result := solve(20)
+
+ fmt.Println("Solved!: ", result)
+}
View
23 15_test.go
@@ -0,0 +1,23 @@
+package fifteen
+
+import (
+ "testing"
+)
+
+func TestExample(t *testing.T) {
+ r := solve(2)
+ e := 6
+
+ if r != e {
+ t.Errorf("Expected %v, got %v", e, r)
+ }
+}
+
+func TestSolve(t *testing.T) {
+ r := solve(20)
+ e := 6
+
+ if r != e {
+ t.Errorf("Expected %v, got %v", e, r)
+ }
+}
View
24 31.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "fmt"
+)
+
+func countChange(money int, coins []int) int {
+ if money == 0 {
+ return 1
+ }
+ if money < 0 {
+ return 0
+ }
+ if len(coins) == 0 && money != 0 {
+ return 0
+ }
+
+ return countChange(money-coins[0], coins) + countChange(money, coins[1:])
+}
+
+func main() {
+ result := countChange(200, []int{1, 2, 5, 10, 20, 50, 100, 200})
+ fmt.Println(result)
+}

No commit comments for this range

Something went wrong with that request. Please try again.