|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func min(numbers ...int) int {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
min := numbers[0]
|
|
|
|
for _, i := range numbers {
|
|
|
|
if i < min {
|
|
|
|
min = i
|
|
|
|
}
|
|
|
|
}
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
return min
|
|
|
|
}
|
|
|
|
|
|
|
|
func max(numbers ...int) int {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
max := numbers[0]
|
|
|
|
for _, i := range numbers {
|
|
|
|
if i > max {
|
|
|
|
max = i
|
|
|
|
}
|
|
|
|
}
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
return max
|
|
|
|
}
|
|
|
|
|
|
|
|
func Costume_profit(a, b, c, d, e, f int) int {
|
|
|
|
if d == min(a, b, c, d) {
|
|
|
|
return d * max(e, f)
|
|
|
|
}
|
|
|
|
if e > f {
|
|
|
|
ans := min(a, d) * e
|
|
|
|
d -= min(a, d)
|
|
|
|
ans += min(d, b, c) * f
|
|
|
|
return ans
|
|
|
|
}
|
|
|
|
ans := min(b, c, d) * f
|
|
|
|
d -= min(b, c, d)
|
|
|
|
ans += min(a, d) * e
|
|
|
|
return ans
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
args := os.Args[1:]
|
|
|
|
a, _ := strconv.Atoi(args[0])
|
|
|
|
b, _ := strconv.Atoi(args[1])
|
|
|
|
c, _ := strconv.Atoi(args[2])
|
|
|
|
d, _ := strconv.Atoi(args[3])
|
|
|
|
e, _ := strconv.Atoi(args[4])
|
|
|
|
f, _ := strconv.Atoi(args[5])
|
|
|
|
|
|
|
|
fmt.Println(Costume_profit(a, b, c, d, e, f))
|
|
|
|
}
|