require'set'instructions=[]File.readlines('08.txt').eachdo|line|code,argument=line.split(' ')instructions.push[code,argument.to_i]endacc=0i=0visited=Set.newuntilvisited.include?icode,argument=instructions[i]visited.addicasecodewhen'nop'# Do nothingi+=1when'acc'acc+=argumenti+=1when'jmp'i+=argumentendendputsacc
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby, part 1: