func (s instructionSet) Execute() (accumulator int, sequence []int, recursionDetected bool) {
	for i := 0; i < len(s); {
		if s[i].hit {
			recursionDetected = true
			break // repeating a previously executed instruction
		}

		sequence = append(sequence, i)
		s[i].hit = true

		switch s[i].operation {
		case jmp:
			i += s[i].argument
			continue // go to new instruction immediately

		case nop:
			// do nothing

		case acc:
			accumulator += s[i].argument
		}

		i++
	}

	return accumulator, sequence, recursionDetected
}
// Execute this instruction set.
Execute this instruction set.
// Execute this instruction set .
func (s instructionSet) Execute() (accumulator int, sequence []int, recursionDetected bool) {
	for i := 0; i < len(s); {
		if s[i].hit {
			recursionDetected = true
			break 
		}
		sequence = append(sequence, i)
		s[i].hit = true
		switch s[i].operation {
		case jmp:
			i += s[i].argument
			continue 
		case nop:
		case acc:
			accumulator += s[i].argument
		}
		i++
	}
	return accumulator, sequence, recursionDetected
}
func ( s instructionSet ) Execute ( ) ( accumulator int , sequence [ ] int , recursionDetected bool ) { for i := 0 ; i < len ( s ) ; { if s [ i ] . hit { recursionDetected = true break } sequence = append ( sequence , i ) s [ i ] . hit = true switch s [ i ] . operation { case jmp : i += s [ i ] . argument continue case nop : case acc : accumulator += s [ i ] . argument } i ++ } return accumulator , sequence , recursionDetected }
Execute this instruction set.
Execute this instruction set .
// repeating a previously executed instruction // go to new instruction immediately // do nothing