The Gold-Bug P35941


Statement
 

pdf   zip

html

Consider a text made up of only lowercase letters, which is encrypted with one of the easiest methods: each letter has an associated character that is always written in its place. Given the translation table and the text encrypted with this table, recover the original text.

Input

Input consists of several cases separated by an empty line. Every case has three parts. The first one is a line with the translation table: 26 different characters (with no spaces nor ‘_’), the first one corresponding to ‘a’, the second one to ‘b’, …, and the last one to ‘z’. The second part is a number n > 0 in a line. The third part consists of n encrypted lines of text.

Output

For each case, write the original text, also with n lines. Change each ‘_’ of the encrypted text for a space. Write an empty line at the end of each case.

Observation

The first example is (basically) extracted from the story “The Gold-Bug” of Edgar Allan Poe. The second text is a famous quotation of Donald Knuth.

Public test cases
  • Input

    52-!813467/09*+.[();?`]<:>
    6
    5_3++!_305))_6*_;48_26)4+.)_4+);80_6*_;48_!8`60)_)85;
    ;]8*;:_+*8_!83(88)_5*!_;46(;88*_96*?;8)
    *+(;485);_5*!_2:_*+(;4
    956*_2(5*-4_)8`8*;4_0692_85);_)6!8
    )4++;_1(+9_;48_081;_8:8_+1_;48_!85;4)_485!
    5_288_06*8_1(+9_;48_;(88_;4(+?34_;48_)4+;_161;:_188;_+?;
    
    bcdefghijklmnopqrstuvwxyza
    3
    cfxbsf_pg_cvht_jo_uif_bcpwf_dpef
    j_ibwf_pomz_qspwfe_ju_dpssfdu
    opu_usjfe_ju
    

    Output

    a good glass in the bishops hostel in the devils seat
    twenty one degrees and thirteen minutes
    northeast and by north
    main branch seventh limb east side
    shoot from the left eye of the deaths head
    a bee line from the tree through the shot fifty feet out
    
    beware of bugs in the above code
    i have only proved it correct
    not tried it
    
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++ Java Python
    User solutions
    C++ Python