Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
coconuts := 11
|
||||
outer:
|
||||
for ns := 2; ns < 10; ns++ {
|
||||
hidden := make([]int, ns)
|
||||
coconuts = (coconuts/ns)*ns + 1
|
||||
for {
|
||||
nc := coconuts
|
||||
for s := 1; s <= ns; s++ {
|
||||
if nc%ns == 1 {
|
||||
hidden[s-1] = nc / ns
|
||||
nc -= hidden[s-1] + 1
|
||||
if s == ns && nc%ns == 0 {
|
||||
fmt.Println(ns, "sailors require a minimum of", coconuts, "coconuts")
|
||||
for t := 1; t <= ns; t++ {
|
||||
fmt.Println("\tSailor", t, "hides", hidden[t-1])
|
||||
}
|
||||
fmt.Println("\tThe monkey gets", ns)
|
||||
fmt.Println("\tFinally, each sailor takes", nc/ns, "\b\n")
|
||||
continue outer
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
coconuts += ns
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue