|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||256 MB||7||1||1||50.000%|
Agnes has heard that the carnival is going to have a new game next year. The carnival guy chooses a word and writes it down on a piece of paper, and only tells you the length of the word (lets call it Word 1). You have to guess a word of the same length (lets call it Word 2), and you earn or lose coins depending on how different are the two words (i.e., based on how much effort is required to swap the two words). Agnes, having just turned 6, has barely started reading and can’t do math yet, so she wants your help to play this game.
The carnival provided the following rules for earning or paying coins.
For example: if the carnival guy wrote down agnes and you guessed heard, then the following table shows the calculation.
|Position 1||Position 2||Position 3||Position 4||Position 5||Total|
|Coins||paid 7||earned 2||earned 13||paid 13||earned 15||earned 10|
You have to write a program that tells Agnes how many coins she will earn or have to pay for a pair of words. The program will read in a series of pairs of words and report the amount paid or earned. The provided skeleton handles the input of the words and the output messages. You need to implement the method costToSwap which returns an integer.
The first line in the test data file contains the number of test cases. After that each line will contain two words separated by a space.
For each test case, the program will display the number of coins paid or earned.
4 agnes heard unicorn minions victor vector sweat waste
Swapping letters to make agnes look like heard earned 10 coins. Swapping letters to make unicorn look like minions earned 1 coins. Swapping letters to make victor look like vector earned 4 coins. Swapping letters to make sweat look like waste was FREE.