Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
14
Task/Search-a-list/Go/search-a-list-1.go
Normal file
14
Task/Search-a-list/Go/search-a-list-1.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
var haystack = []string{"Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty",
|
||||
"Charlie", "Bush", "Bozo", "Zag", "mouse", "hat", "cup", "deodorant",
|
||||
"television", "soap", "methamphetamine", "severed cat heads", "foo",
|
||||
"bar", "baz", "quux", "quuux", "quuuux", "bazola", "ztesch", "foo",
|
||||
"bar", "thud", "grunt", "foo", "bar", "bletch", "foo", "bar", "fum",
|
||||
"fred", "jim", "sheila", "barney", "flarp", "zxc", "spqr", ";wombat",
|
||||
"shme", "foo", "bar", "baz", "bongo", "spam", "eggs", "snork", "foo",
|
||||
"bar", "zot", "blarg", "wibble", "toto", "titi", "tata", "tutu", "pippo",
|
||||
"pluto", "paperino", "aap", "noot", "mies", "oogle", "foogle", "boogle",
|
||||
"zork", "gork", "bork", "sodium", "phosphorous", "californium",
|
||||
"copernicium", "gold", "thallium", "carbon", "silver", "gold", "copper",
|
||||
"helium", "sulfur"}
|
||||
|
|
@ -2,19 +2,6 @@ package main
|
|||
|
||||
import "fmt"
|
||||
|
||||
var haystack = []string{"Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty",
|
||||
"Charlie", "Bush", "Bozo", "Zag", "mouse", "hat", "cup", "deodorant",
|
||||
"television", "soap", "methamphetamine", "severed cat heads", "foo",
|
||||
"bar", "baz", "quux", "quuux", "quuuux", "bazola", "ztesch", "foo",
|
||||
"bar", "thud", "grunt", "foo", "bar", "bletch", "foo", "bar", "fum",
|
||||
"fred", "jim", "sheila", "barney", "flarp", "zxc", "spqr", ";wombat",
|
||||
"shme", "foo", "bar", "baz", "bongo", "spam", "eggs", "snork", "foo",
|
||||
"bar", "zot", "blarg", "wibble", "toto", "titi", "tata", "tutu", "pippo",
|
||||
"pluto", "paperino", "aap", "noot", "mies", "oogle", "foogle", "boogle",
|
||||
"zork", "gork", "bork", "sodium", "phosphorous", "californium",
|
||||
"copernicium", "gold", "thallium", "carbon", "silver", "gold", "copper",
|
||||
"helium", "sulfur"}
|
||||
|
||||
func main() {
|
||||
// first task
|
||||
printSearchForward("soap")
|
||||
13
Task/Search-a-list/Go/search-a-list-3.go
Normal file
13
Task/Search-a-list/Go/search-a-list-3.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
m := map[string][]int{}
|
||||
for i, needle := range haystack {
|
||||
m[needle] = append(m[needle], i)
|
||||
}
|
||||
for _, n := range []string{"soap", "gold", "fire"} {
|
||||
fmt.Println(n, m[n])
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue