mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
834 B
44 lines
834 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
5 years ago
|
import (
|
||
5 years ago
|
student "student"
|
||
|
|
||
|
"lib"
|
||
5 years ago
|
)
|
||
5 years ago
|
|
||
|
// Returns the element of the slice that doesn't have a correspondant pair
|
||
5 years ago
|
func unmatch(elems []int) int {
|
||
5 years ago
|
var quant int
|
||
5 years ago
|
for _, el := range elems {
|
||
5 years ago
|
quant = 0
|
||
5 years ago
|
for _, v := range elems {
|
||
5 years ago
|
if v == el {
|
||
|
quant++
|
||
|
}
|
||
|
}
|
||
|
if quant%2 != 0 {
|
||
|
return el
|
||
|
}
|
||
|
}
|
||
|
return -1
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
i1 := lib.RandIntBetween(-100, 100)
|
||
|
i2 := lib.RandIntBetween(-1000, 1000)
|
||
|
i3 := lib.RandIntBetween(-10, 10)
|
||
|
args := [][]int{
|
||
|
{1, 1, 2, 3, 4, 3, 4},
|
||
|
{1, 1, 2, 4, 3, 4, 2, 3, 4},
|
||
|
{1, 2, 1, 1, 4, 5, 5, 4, 1, 7},
|
||
|
{1, 2, 3, 4, 5, 6, 7, 8},
|
||
|
{0, 20, 91, 23, 10, 34},
|
||
|
{1, 1, 2, 2, 3, 4, 3, 4, 5, 5, 8, 9, 8, 9},
|
||
|
{i1, i2, i1, i2, i1 + i3, i1 + i3},
|
||
|
{i1, i2, i1, i2, i1 + i3, i2 - i3},
|
||
|
}
|
||
5 years ago
|
for _, v := range args {
|
||
5 years ago
|
lib.Challenge("Unmatch", student.Unmatch, unmatch, v)
|
||
5 years ago
|
}
|
||
|
}
|