Ordinarily, advertisers strive to make their messages as clear as possible. In fact, most are designed to get through to the village idiot. In 1972, publisher Addison-Wesley placed an advertisement with a different twist. On the back of the magazine The American Statistician, they led off an ad for three textbooks with the following cryptic remark.
David Silverman wrote in an article for the magazine Word Ways:
Care to try and figure out the hidden message? Although the slogan doesn't have the pizzazz of — say — "Let ESSO put a tiger in your tank", it can equally well be applied to the sale of shoes, ships or sealing wax (or, for that matter, floor wax).
The first line contains a text fragment that hides a secret message that can be deciphered in the same way as the pitch line from the Addison-Wesley advertisement from the introduction. This is followed by another two lines that each contain an integer: a starting position $$p$$ in the pitch line and a step size $$s$$, where $$s \neq 0$$.
A line containing the secret message. The message can be deciphered by stepping through the pitch line starting from position $$p$$ and skipping $$s$$ characters forward (if $$s > 0$$) or backward (if $$s < 0$$) at a time through the string. Positions of the characters are indexed according to the Python indexing rules for strings (including negative indices). Cycle back to the beginning if you hit the end of the pitch line when skipping forward. Cycle back to the end if you hit the beginning of the pitch line when skipping backward.
This shows how to decipher the secret message from the cryptic remark in the Addison-Wesley advertisement mentioned in the introduction. We start at position -3 (or position 20 if we index left to right) and keep on skipping three positions backward through the characters of the string, cycling back to the end as often as necessary. The starting position and the first step of the deciphering process are marked in yellow.
Input:
y luaeb h o dtyo aoosgl
-3
-3
Output:
say hello to a good buy
Input:
say hello to a good buy 22 15
Output:
y luaeb h o dtyo aoosgl