Didn't really find this one interesting. Apparently it's a known series.
Either way, Ruby it was:
numbers=File.read('input.txt').chomp.split(',').map(&:to_i)turns=numbers.dupmemory=Hash.new{[]}numbers.each_with_indexdo|number,turn|memory[number]=[turn]puts"Turn #{turn+1}: #{number}"endgoal=30000000whileturns.length<goalturn=turns.lengthprevious=turns.lastbefore_last,last=memory[previous][-2..]speak=last.nil??0:last-before_last# You could store only the last two numbers, but with this set of data there# is really no pointmemory[speak]=memory[speak].push(turn)puts"Turn #{turn+1}, speaking #{speak} (#{(turn/goal.to_f*100).round}%)"if(turn+1)%(goal/100)==0turns.pushspeakendputsturns.last
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.
Didn't really find this one interesting. Apparently it's a known series.
Either way, Ruby it was: