B:BD[
2.866] → [
2.866:918]
return 0, fmt.Errorf("unrecognized instruction")
return 0, 0, fmt.Errorf("unrecognized instruction")
}
}
}
func fixCode(data []string) (int, error) {
for i := range data {
line := strings.Split(data[i], " ")
var l string
switch line[0] {
case "jmp":
l = "nop " + line[1]
case "nop":
l = "jmp " + line[1]
default:
// no change
continue
}
newdata := make([]string, len(data))
copy(newdata, data)
newdata[i] = l
acc, last, err := readCode(newdata)
if err != nil {
return 0, err
}
if last == len(data) {
return acc, nil