master > master: code, go - bugs behoben (out of bounds + Konversion fand nicht statt)

This commit is contained in:
RD 2021-11-03 19:46:51 +01:00
parent d6bc4b9d72
commit 1a387ac308
2 changed files with 8 additions and 2 deletions

View File

@ -38,6 +38,9 @@ func JumpSearchLinear(L []int, x int, m int) int {
// ACHTUNG: dies ist eine while-Schleife ist golang:
for i0 < len(L) {
metrics.AddTimeCost()
if i1 > len(L) {
i1 = len(L)
}
block := L[i0:i1]
elementAfterBlock := block[len(block)-1] + 1
if x < elementAfterBlock {
@ -74,6 +77,9 @@ func JumpSearchExponentiell(L []int, x int) int {
// ACHTUNG: dies ist eine while-Schleife ist golang:
for i0 < len(L) {
metrics.AddTimeCost()
if i1 > len(L) {
i1 = len(L)
}
block := L[i0:i1]
elementAfterBlock := block[len(block)-1] + 1
if x < elementAfterBlock {

View File

@ -463,8 +463,8 @@ func PromptInputListOfZeroOnes(name string, descr string, requirements []string)
Response: &response,
}
cancel, err := query.Prompt()
// konvertiere in int
if !cancel && err != nil {
// uint8 -> int
if response.Response != nil {
for _, x := range response.Response {
values = append(values, int(x))
}