Skip to content

Instantly share code, notes, and snippets.

@thiagozs
Created May 26, 2020 20:15
Show Gist options
  • Save thiagozs/3f487f816dbd40f30a23493a0941e253 to your computer and use it in GitHub Desktop.
Save thiagozs/3f487f816dbd40f30a23493a0941e253 to your computer and use it in GitHub Desktop.
Challenge QuintoAndar
package main
import (
"fmt"
)
func main() {
A := []int{0, 3, 3, 7, 5, 3, 11, 1}
B := []int{0, 3, 0, 7, 0, 0, 11, 0}
C := []int{80, 80, 1000000000, 80, 80, 80, 80, 80, 80, 123456789}
fmt.Println("reduce", reduce(A))
fmt.Println("reduce", reduce(B))
fmt.Println("reduce", reduce(C))
}
func reduce(arr []int) int {
mapper := map[uint64]uint64{}
for _, k := range arr {
if k%2 == 0 {
mapper[uint64(k)] = uint64(k)
}
}
return len(mapper) + 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment