Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add riddles #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions meetup_2018_11_20/go-quizzes/1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"fmt"
)

// https://twitter.com/davecheney/status/1053490060492890118
func main() {
one, two, three := 0.1, 0.2, 0.3
fmt.Println(one+two > three)
}

// True
// False
// 0.3
19 changes: 19 additions & 0 deletions meetup_2018_11_20/go-quizzes/10.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import "fmt"

func four(s []int) {
s = append(s, 4)
}

// https://twitter.com/davecheney/status/1019359774264082432
func main() {
s := []int{1, 2, 3}
four(s)
fmt.Println(s)
}

// [ 1 2 3 4 ]
// [ 4 ]
// [ 1 2 3 ]
// doesn't compile
14 changes: 14 additions & 0 deletions meetup_2018_11_20/go-quizzes/2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "fmt"

// https://twitter.com/davecheney/status/1056487208989773824
func main() {
ಠ_ಠ := '7'
fmt.Println(ಠ_ಠ)
}

// ಠ_ಠ
// 55
// 7
// dude, that won't compile
16 changes: 16 additions & 0 deletions meetup_2018_11_20/go-quizzes/3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
)

// https://twitter.com/davecheney/status/1053419185680744448
func main() {
var a []int
b := a[:]
fmt.Println(b == nil)
}

// true
// false
// panic on line 9
16 changes: 16 additions & 0 deletions meetup_2018_11_20/go-quizzes/4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
)

// https://twitter.com/davecheney/status/1042396099443453952
func main() {
for i := 1; i < 10; i++ {
fmt.Println("Hello!")
}
}

// Yes
// No
// Only on Windows
17 changes: 17 additions & 0 deletions meetup_2018_11_20/go-quizzes/5.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"crypto/sha1"
"fmt"
)

// https://twitter.com/davecheney/status/1041526653141147654
func main() {
input := []byte("Hello, playground")
hash := sha1.Sum(input)[:5]
fmt.Println(hash)
}

// 461ec8144f
// [70 30 200 20 79]
// nothing, doesn't compile
15 changes: 15 additions & 0 deletions meetup_2018_11_20/go-quizzes/6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"fmt"
)

// https://twitter.com/davecheney/status/1039997464361623552
func main() {
fmt.Println(string('7' << 1))
}

// 7
// 14
// n
// doesn't compile
23 changes: 23 additions & 0 deletions meetup_2018_11_20/go-quizzes/7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"runtime"
"sync"
)

// https://twitter.com/davecheney/status/1031699003803463680
func main() {
var wg sync.Waitgroup
wg.Add(1)
go func() {
defer wg.Done()
runtime.Goexit()
}()
wg.Wait()
fmt.Println("Hello, playground")
}

// Hello, playground
// It panics
// Nothing, it don'st compile
17 changes: 17 additions & 0 deletions meetup_2018_11_20/go-quizzes/8.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import "fmt"

type Q struct{}

func (Q) Hola() string { return "Bueno" }

// https://twitter.com/davecheney/status/1031389514890006528
func main() {
var q Q
fmt.Println(Q.Hola(q))
}

// Bueno
// Good
// Nada, it won't compile
14 changes: 14 additions & 0 deletions meetup_2018_11_20/go-quizzes/9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
)

// https://twitter.com/davecheney/status/1027826127841112064
func main() {
fmt.Println(1)
}

// "1"
// doesn't compile
// 1