Created
December 15, 2019 12:28
-
-
Save siisee11/368269a517c3152bf94bb416a6d616d3 to your computer and use it in GitHub Desktop.
programmers moketest quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package moketest | |
func Solution(answers []int) []int { | |
answer := []int{} | |
picker1 := [5]int{1, 2, 3, 4, 5} | |
picker2 := [8]int{2, 1, 2, 3, 2, 4, 2, 5} | |
picker3 := [10]int{3, 3, 1, 1, 2, 2, 4, 4, 5, 5} | |
correct := [3]int{0, 0, 0} | |
for i, v := range answers { | |
if v == picker1[i % len(picker1)] { | |
correct[0]++ | |
} | |
if v == picker2[i % len(picker2)] { | |
correct[1]++ | |
} | |
if v == picker3[i % len(picker3)] { | |
correct[2]++ | |
} | |
} | |
m := 0 | |
for i, e := range correct { | |
if i==0 || e > m { | |
m = e | |
} | |
} | |
for i, e := range correct { | |
if e == m { | |
answer = append(answer, i + 1) | |
} | |
} | |
return answer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment