Programming contests

DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2016. december 4.

December 4, 2016 10:10 AM – December 4, 2016 3:10 PM

No CAPTCHA, Please!

CAPTCHA (Completely Automated Public Turing Test To Tell Computers and Humans Apart) is supposed to be able to tell apart human and computer bots by asking a user to solve a simple puzzle, often a series of random letters scrambled with random lines and stuff. Examples of CAPTCHA puzzles are shown below:

Source: http://www.extremetech.com/wp-content/uploads/2011/11/captcha-selection1.jpg.

However, sadly I always have problems solving many CAPTCHAs, especially ones with a mixture of lowercase and uppercase letters. I always get them wrong during the first few tries. So no more hard CAPTCHA, please!! Your task is to write a program that is lenient on my poor skill of solving a CAPTCHA challenge. The program should do the followings:

  1. The program should treat lowercase and uppercase letters that look similar the same. Specifically, if the correct letter is an uppercase letter (in the table below), but I answer the lowercase version of the letter (in the table below), then the letter is treated as correct, and vice versa. The letter pairs that are often confused are shown in the table below. For other pairs, e.g., G and g, the user must answer them strictly as G and g, respectively.
    C c K k S s V v Y y
    E e O o T t W w Z z
    F f P p U u X x I l *
    * I is an uppercase I as in “Indian”, while l is a lowercase letter l as in “love”.
    For example, if the CAPTCHA is (7d6bf), and I answer 7d6bF, this should be correct.
  2. The program should tolerate one mistake for a CAPTCHA that has a length of more than 5 letters, excluding the mistakes from item 1.
    For example, if the CAPTCHA is (7d6bf), and I answer 2d6bf, this is wrong (one mistake, but there are only 5 letters).
    But if the CAPTCHA is (apricot), and I answer aPricod, this should be correct (one mistake for a 6-letter word).

Input Specification

The input contains several test cases. A test case consists of 2 words in the same line, separated by a space. The first word is a correct CAPTCHA, and the second word is what I answer. The two words will always be of the same length. The number of test cases is unknown, the input is terminated by end-of-file (EOF).

Output Specification

For each test case, your program should output either “Right” (if I answer the CAPTCHA correctly) or “WRONG” (if I answer it incorrectly), followed by a space and the number of mistakes.

Sample Input

  1. 7d6bf 7d6bF
  2. 7d6bf 2d6bf
  3. apricot aPricod
  4. ACM-icpC ADm-iCeC
  5. Girl girl
download as text file

Output for Sample Input

  1. Right 0
  2. WRONG 1
  3. Right 1
  4. WRONG 3
  5. WRONG 1
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019