fork(3) download
  1. x=y=n=d=0
  2. g=gets.to_i
  3. "#{[43435,102,45,t=45,12,t,12,t,t][g+~d]||12}".chars{|c|n+=1
  4. puts [eval(["x-=t=[3-y,x].min;y+=t"+t=";'Pour from 5L jug into 3L jug'","x=5;'Fill 5L jug'","d+=x;x=0"+t.sub(/3.+/,"tank'")][c.ord%3].tr t='35xy',c<?4?t:'53yx'),"5L: #{x}, 3L: #{y}, T: #{d}"]}while g>d
  5. $><<"Volume measured out in #{n} turns"
Success #stdin #stdout 0.02s 7432KB
stdin
11
stdout
Fill 5L jug
5L: 5, 3L: 0, T: 0
Pour from 5L jug into tank
5L: 0, 3L: 0, T: 5
Fill 3L jug
5L: 0, 3L: 3, T: 5
Pour from 3L jug into tank
5L: 0, 3L: 0, T: 8
Fill 3L jug
5L: 0, 3L: 3, T: 8
Pour from 3L jug into tank
5L: 0, 3L: 0, T: 11
Volume measured out in 6 turns