1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Solution of Task 1 of The Weekly Challenge 263
// https://theweeklychallenge.org/blog/perl-weekly-challenge-263/
/*
$ go run ch-1.go
[1 2]
[]
[4]
*/
package main
import (
"fmt"
"sort"
)
func main() {
tests := [][]int{
{1, 5, 3, 2, 4, 2},
{1, 2, 4, 3, 5},
{5, 3, 2, 4, 2, 1},
}
values := []int{2, 6, 4}
for t, test := range tests {
sort.Ints(test)
var indices []int
for i, n := range test {
if n == values[t] {
indices = append(indices, i)
}
}
fmt.Println(indices)
}
}
|