#!/usr/koeki/bin/ruby STDERR.print "出発 : " start = STDIN.gets.chomp stop1 = Regexp.new(start, true, "e") STDERR.print "目的 : " goal = STDIN.gets.chomp stop2 = Regexp.new(goal, true, "e") while station = gets if stop1 =~ station if /(\S+)\s+(\d+)/ =~ station station1 = $1 length1 = $2.to_i end end if stop2 =~ station if /(\S+)\s+(\d+)/ =~ station station2 = $1 length2 = $2.to_i end end end length = length1 - length2 if length < 0 length = -1 * length end price = 100 + length * 20 printf("%s -- %s : 大人 %d 円\n",station1, station2, price)