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 files via upload #3

Open
wants to merge 8 commits 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
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module golang-united-school-homework-3-

go 1.17
14 changes: 12 additions & 2 deletions task01-arrays.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package homework

func average(input [15]float32) (result float32) {
//Place your code here
return
var sum float32
var N float32
for _, v := range input {
if v > 0 {
sum += v
N++
} else {
break
}
}
result = sum / N
return result
}
9 changes: 7 additions & 2 deletions task02-slice.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package homework

import "sort"

func reverse(input []int64) (result []int64) {
//Place your code here
return
sort.Slice(input, func(i, j int) bool {
return input[i] > input[j]
})
result = input
return result
}
13 changes: 11 additions & 2 deletions task03-map.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package homework

import "sort"

func sortMapValues(input map[int]string) (result []string) {
//Place your code here
return
var preresult []int
for i := range input {
preresult = append(preresult, i)
}
sort.Ints(preresult)
for _, v := range preresult {
result = append(result, input[v])
}
return result
}