Pizzino (plural: pizzini) is an Italian language word derived from Sicilian language equivalent pizzinu. Despite it generically meaning "small piece of paper", the word is now widely used to refer to small slips of paper that the Sicilian Mafia uses for high-level communications. Sicilian Mafia boss Bernardo Provenzano is among those best known for using pizzini, most notably in his instruction that Messina Denaro become his successor. The pizzini of other mafioso have significantly aided police investigations about the Sicilian Mafia.

Bernardo
      Provenzano
Bernardo Provenzano (born January 31, 1933 in Corleone, Sicily) is a member of the Sicilian Mafia (Cosa Nostra) and is suspected of having been the head of the Corleonesi, a Mafia faction that originated in the town of Corleone, and de facto capo di tutti capi (boss of bosses) of the entire Sicilian Mafia until his arrest in 2006. His nickname is Binnu u tratturi (Sicilian for "Binnie the tractor") because, in the words of one informant, "he mows people down."

Provenzano hid the pizzini containing his instructions at an old sheep farm under rocks or under the ground. The were immediately destructed after reading. Provencano's pizzini also used a code in which letters replaced by numbers indicating their position in the alphabet (A=1, B=2, …). Each of these number was than incremented by three. The numbers thus obtains for each of the letters in a word, were simply concatenated to and up with a large number. This mia might become 16124, because \[\mbox{m} = 13 + 3 = 16,\ \mbox{i} = 9 + 3 = 12 \mbox{ en a} = 1 + 3 = 4\] Note that the alphabet used is the Italian alphabet, which has a slightly different order and number of characters than the Latin alphabet:

ABCDEFGHILMNOPQRSTUVZ

All in all, this was a very simple and old code (tracing back to Julius Caesar wartime communications), with the only point of difficulty being the initial confusion of the ambiguous role of the various digits as independent or part of two-digit numbers. For example, one reported note by Provenzano read

I met 512151522 191212154 and we agreed that we will see each other after the holidays…

This name was decoded as Binnu Riina. Bruce Schneider — an American cryptography expert — was quoted in Discovery Channel News saying

Looks like kindergarten cryptography to me. It will keep your kid sister out, but it won't keep the police out. But what do you expect from someone who is computer illiterate?

Italian police got a chance to read many pizzini when close associates of Provenzano turned informant. Once in possession of enough pizzini, police were able to break the code quickly. A biographer of Provenzano also reports that Provenzano used a more complicated code — yet to be deciphered — which referenced selected words that Provenzano had underlined in his copy of the Bible.

Assignment

In this assignment we ask you to encode words as positive integers, using an encryption scheme inspired by the code Provenzano used to write his pizzini. In doing you, you proceed as follows.

In both functions, the third argument represents a given alphabet, in which you may assume that each character occurs only once. In addition you may assume in both cases that all characters of the string passed as the first argument occur in the given alphabet. Both function should make no distinction between uppercase and lowercase letters.

Example

>>> italian = 'ABCDEFGHILMNOPQRSTUVZ'
>>> encodeLetter('M', 3, italian)
14
>>> encodeWord('MIA', 3, italian)
14124
>>> encodeWord('Binnu', 3, italian)
512151522
>>> encodeWord('Riina', 3, italian)
191212154

>>> latin = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> encodeLetter('M', 3, latin)
16
>>> encodeWord('MIA', 3, latin)
16124
>>> encodeWord('Binnu', 3, latin)
512171724
>>> encodeWord('Riina', 3, latin)
211212174