a = ["L","R"] t = 0 loop{ s = gets.to_i if s > 0 puts "F" STDOUT.flush if s > 20 break end else puts a[t] STDOUT.flush s = gets.to_i if s == 0 puts a[t] STDOUT.flush s = gets.to_i puts a[t] STDOUT.flush t = 1 - t else puts "F" STDOUT.flush if s > 20 break end end end } loop { s = gets if s[0] == "M" break else puts "F" STDOUT.flush end }