The Dislex-Wonga test

This year four adventurers went on vacation to Potige, a city in Kerala
(India), and they discovered some Indians who speak a strange language
called Malayalam. As a language already in development (let’s say, like
a beta version), it does not have too many grammatical rules yet.

The main rule is that all words must pass the Dislex-Wonga test. This
primitive test consists in painting the letters of the word on a huge
wall. Afterwards, two Indians get on a stage, and they start reading
(singing) the word, one starting from the beginning and the other one
from the end, in opposite directions. The word passes the test if both
Indians sing the same song.

Neuquen, the chief of the Potige tribe, imposes adding the necessary
letters until the word passes the Dislex-Wonga test, and charges a tax
of one rupee on each letter added. Your mission is to help the poor guy
who invented the word, so that he pays the least possible money to
Neuquen.

[]

Input

Input consists of several words w of length between 1 and 2000, made up
only of lowercase letters, uppercase letters, and digits.

Output

For every w, compute the minimum number of necessary characters to add
in order to pass the Dislex-Wonga test. If the answer is zero, print
“Passes the Dislex-Wonga test”.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:17:00.773Z

© Jutge.org, 2006–2026.
https://jutge.org
