Parchment Challenge¶
This challenge consists of deciphering a scroll from Python code
First let’s look at the structure of the scroll texts.
Archaeologists found a parchment with the following texts: txt_A
and txt_B
.
xxxxxxxxxx
txt_A = '''cncdbm pjcjzct vdbbxdtw rfqsr mkt gvhkcsvw qcxr kmk pnhc zwwdsd pgjjhr
lxzscps lmbjjx lgh mdcqlbwx ppzpvfbv vdszkb njv nvmfhshh ztvkmv dfbnht xfpj nlbcwrvv
dcrzslrf wzb krdb zndtfmf fwwm vmqzmg cpcnpnww nkjk ncrmzr jfmcl hxr vcj wcptgbc
gvbfxtbv wcjlrs psjc lrljqdct ltjwn vmhp wnlmw rkvg rtm djsv rwjls ngc zcjjttpt kbg
tdjzcwj pmgtzlng zvtnbs svztn pctgq qnghqcch mclvp qdht cbk lvqckrl qmwknt cqw jfxzx
tkljpkfc mjhskxjh lfjvrhr whshcrk kvtgzpl gxglr mpqxtbzb zbrpktxj knhmmtks mhj xdlsm
wcc sbrkdjmh gpn vwddsdl mqfsrwt khhmfng qkkjgg qdr qlpt njq xlc jfhhv kgzsb lqncvrh
jgw xhjk krprtxf dtrsfb rwtzbhs qbvvz nqbh pdfqlsv hhrrx pvf mdvcfqkt bsb gcnkszfk
rkzlhbnx njfqrzxj gtvrwp cmgp qddg gqjjcbjw khlbtg cdswmbgb lmbfvsv nfhvn jbnplx gkh
dmp hmnf bzrznlh vqdmjdsb ktbcx fgvsxzp gmv xftg lxtf dcxsrkl tzwvbkfq tpvdrlf khzzw
srtfttv lmknq jvkwr bplzzpjw rgtrj gcmdfzdx ksptr jzdfqq xmtzz pkqxrsw gvwg fqppvgk hsc
hdj gthkq trxl gkhp rbr skxpc lbkw bbdqpvn llshm bhrfvh gjw zgnlpgwl pdhqn ttjtx vfb
djftp kkrr ptmnzqkg tmjlqw pcvpwjb ggd jntktdz vth wtsp mlfmddsn phn hrdqrds phbq
vkffrqvt zxljnd lqg blnw brxk skwkh vqbq dlbnhz xpbddsjw gscvghmj pxcpvkmm jsfpllns
kpmmgxb pljpvcn wknwbcq wthwv bdjxr wdc lqmtsnrn wbcjprr htldnxcn qwl fvjdqd cwmb bfjmw
chv blx xblfrb gjbbg njqw mkmnwtzv dgsxl tgtclv xxcfpp brzxg lbrnrsf pfcpt wmvjxdsw
jmstqwx zjcrkzm ndtbsqsh jqbcddqh ggvf kcr mfhllb lbbkssx gsrxcb rwtxljp cwkc xwxjhbc
pfcgz zbdbsq wzfsf gqhdfchv cgp kwvnrfm ptmzl bkjcm dpl rskfms mqdgvskt hbtjpvm swff
vjq dwlrgxtm kqzrlxz vmpdxkv bwfgzmjn zzrr mlsm kknhkq jhtxc gjvnj mcld vftnnd pgbkhc
kzzsbq xqbs hlkxtc xgj vttn zmnc kwhcrd bfjbs lxkmnzx pbmp lnt ztm fkzql bjgllxv
bghqpnl hphvdvl lwlqdh xldsnqds tsmrhhtm gnksf lzhr rqm jvcmkbxv nsx cxpplqbq jzrr tnt
wpfl lnkfqjt tplwbr hzrv mxqhpg xxzdlwzx cgrtr jbvqmb cmsqdjx qcrx ljxh jbnw lgf tzd
cltdd jtmdmt djbgqqk tgsffh hbff jjqn wtlsx qlmhxrrf sklfrc dwsk rgpgqz zhzvm brprszrc
hqlgx tdbsgf fkmrtn frskk qjvg jlhpgh rxrmqp nmc dxpx lljs kszjq hlxx nbkvsrf dggshkxz
Activity: 1 ActiveCode (ac_r02_1_en)
These scrolls are in the ancient and mysterious Googlon language. After many years of study, Linguists already know some characteristics of this language. First, Googlon letters are classified into two groups: letters z, m, b are called “zombie type letters”, while the others are known as “survivor type letters”. Linguists have discovered that prepositions on Googlon are words that begin with a zombie-type letter and end with another letter, it is easy to see that there are 71 prepositions in Text A.
Calculate how many prepositions exist in text B. Assign the result to the variable
prep_B
. Note: txt_A
and txt_B
are already defined even though they do not appear in the window
of code below.
zombie = "zmb"
Activity: 2 ActiveCode (ac_r02_2_en)
Another interesting fact discovered by linguists is that, on Googlon, verbs are always 7-letter words that end in a survivor type letter. Furthermore, if a verb begins with a surviving type letter, the verb is in the first person. Thus, reading Text A, it is possible identify 84 verbs in the text, of which 70 are in the first person.
Calculate how many verbs there are in Text B, and assign that value to the variable verbs_B
. After
calculate how many of those verbs are in the first person, and assign that value to the variable person_1_B
.
Remember: the texts are already defined, as is the zombie
variable in the code above.
person_1_B = 0
Activity: 3 ActiveCode (ac_r02_3_en)
A university professor will use texts A and B to teach Googlon to students. To help students understand the text, this teacher needs to create a list of vocabulary for each text, that is, an ordered list of the words that appear in each one of the texts. These lists must be sorted. In Googlon, as in our alphabet, the words are ordered lexicographically, but the problem is that in Googlon, the order of The letters in the alphabet are different from ours. Its order is: zmbtshjpnwlrcxkqvdgf. Therefore, when making these lists, the teacher must respect Googlon’s alphabetical order.
The teacher prepared the (ordered) vocabulary list for Text A; look at it in the variable
list_A
. What would be the ordered vocabulary list for Text B? Make a program that performs
this list, and save it in the variable list_B
. Remember: the texts are already defined as
in the first exercise (Exercise 1).
'mfhllb', 'bzrznlh', 'bzccxd', 'bzqcnzwp', 'bzfqkpjj', 'bmzqtdx', 'bmt', 'bbzvs', 'bbdqpvn', 'bsb', 'bslbmwm', 'bhrfvh', 'bjgllxv', 'bpngkf', 'bplzzpjw', 'bwfgzmjn', 'blnw', 'blx', 'brzxg', 'brprszrc', 'brxk', 'bkjcm', 'bvrjztfm', 'bdjxr', 'bdnfbh', 'bghqpnl', 'bfjmw', 'bfjbs', 'tzhqvbt', 'tzwvbkfq', 'tzqcvz', 'tzd', 'tmjlqw', 'tbw', 'ttjtx', 'ttl', 'tsmrhhtm', 'tjpdp', 'tjw', 'tjgmjzh', 'tpppxf', 'tplwbr', 'tpvdrlf', 'tnbqgv', 'tnt', 'twjhgcc', 'twxcfxk', 'tlthnhrh', 'trzz', 'trxl', 'trvpx', 'txz', 'tkljpkfc', 'tqbs', 'tvphkg', 'tvpjwzb', 'tdbsgf', 'tdsbdhv', 'tdjzcwj', 'tgmwmsc', 'tgtclv', 'tgsffh', 'tgjpq', 'tgnq', 'tgq', 'szzh', 'szbmqd', 'szltzjm', 'smtkrxjx', 'smdlrm', 'sbst', 'sbnfjs', 'sbrkdjmh', 'spzzbc', 'swff', 'srtfttv', 'srwg', 'sxcdqtlt', 'skhcwxw', 'skwkh', 'sklfrc', 'skxpc', 'skkfq', 'svztn', 'sfwsnkkw', 'hzrv', 'hzdb', 'hmnf', 'hbtjpvm', 'hbff', 'htldnxcn', 'htkmdbx', 'hsc', 'hhrrx', 'hhcxnnhn', 'hphvdvl', 'hwfbd', 'hljqwkz', 'hlnls', 'hlxx', 'hlkxtc', 'hrdqrds', 'hcr', 'hxr', 'hqlgx', 'hdslhv', 'hdj', 'hgsx', 'hffjd', 'jzzpb', 'jzrr', 'jzdfqq', 'jmstqwx', 'jmqkbclx', 'jbmlsfkx', 'jbnplx', 'jbnw', 'jbw', 'jbvqmb', 'jtmdmt', 'jtwhxdx', 'jsfpllns', 'jsfkd', 'jhztz', 'jhtxc', 'jjqn', 'jplzc', 'jntktdz', 'jlhpgh', 'jlgz', 'jcw', 'jxsd', 'jxnng', 'jkk', 'jqbcddqh', 'jqjgd', 'jvcmkbxv', 'jvkwr', 'jvvc', 'jgw', 'jgl', 'jfmcl', 'jfhhv', 'jfxzx', 'pznlvfk', 'pmmd', 'pmnt', 'pmgtzlng', 'pbmp', 'ptmzl', 'ptmnzqkg', 'ptg', 'psjc', 'phbq', 'phn', 'phk', 'pjcjzct', 'ppzpvfbv', 'ppsp', 'pphslgf', 'pnhc', 'pwpznr', 'pljpvcn', 'plphnnv', 'plkxf', 'pctgq', 'pcl', 'pcvpwjb', 'pxcpvkmm', 'pkqxrsw', 'pqsq', 'pqc', 'pvf', 'pdhqn', 'pdnqm', 'pdxjxpxr', 'pdfqlsv', 'pgbkhc', 'pgjjhr', 'pgwd', 'pfcpt', 'pfcgz', 'pfkjshg', 'nmmqnzfn', 'nmc', 'nmdzgmnr', 'nbkvsrf', 'nsx', 'njq', 'njqw', 'njv', 'njfqrzxj', 'nwjjkrdq', 'nlbcwrvv', 'nlvgr', 'nrpzqfr', 'ncrmzr', 'nkjk', 'nqbh', 'nqjflf', 'nvmfhshh', 'nvb', 'ndtbsqsh', 'ngsbphqb', 'ngwrbrfk', 'ngc', 'ngkgnln', 'ngqzs', 'nfhvn', 'nfkltv', 'nfv', 'wzb', 'wzg', 'wzfsf', 'wmvjxdsw', 'wbht', 'wbcjprr', 'wtsp', 'wthwv', 'wtlsx', 'wtfh', 'whshcrk', 'whnjkv', 'wjg', 'wptc', 'wpfl', 'wnlmw', 'wwmngbk', 'wlsxsvf', 'wlj', 'wrzct', 'wrsctd', 'wrgf', 'wcjlrs', 'wcptgbc', 'wcpn', 'wcc', 'wxxchz', 'wknwbcq', 'wkq', 'wdc', 'wdxmfr', 'wfqxrnzf', 'wffrgzp', 'lzhr', 'lzq', 'lzgfnkmg', 'lmbtkhch', 'lmbjjx', 'lmbfvsv', 'lmknq', 'lmq', 'lbbkssx', 'lbrnrsf', 'lbkw', 'lbqjrp', 'ltjwn', 'ltqxkt', 'lsmphpk', 'ljxh', 'ljdz', 'lphf', 'lnt', 'lnkfqjt', 'lwlqdh', 'lwdbkws', 'llshm', 'lljs', 'lllkssb', 'lrljqdct', 'lxzscps', 'lxtf', 'lxkmnzx', 'lqmtsnrn', 'lqncvrh', 'lqg', 'lvwht', 'lvq', 'lvqckrl', 'lgh', 'lgf', 'lfhkmb', 'lfjvrhr', 'rzp', 'rmmhtmbp', 'rbr', 'rtm', 'rtb', 'rtxct', 'rskfms', 'rsqb', 'rsd', 'rhhmzvp', 'rjldhzld', 'rpxwnbrw', 'rwtzbhs', 'rwtxljp', 'rwjls', 'rrflt', 'rcfxhhh', 'rxrmqp', 'rkzlhbnx', 'rkvg', 'rqm', 'rqkr', 'rdrphff', 'rgtrj', 'rgpgqz', 'rflzw', 'rfqsr', 'rfqdh', 'czhhtclr',
Activity: 4 ActiveCode (ac_r02_4_en)
But how do Googlons write numbers? Well, on Googlon, words are too numbers given in base 20, where each letter is a digit. On Googlon, the first position is the unit and corresponds to the letter to the left of the word, the second position has a value of 20, the third 400 and so on. Letter values are given in the order they appear in the Googlon alphabet (which is different from our order, as we saw above). That is, the first letter of the alphabet Googlon, which is the z, represents the digit 0, the second represents the digit 1, and so on.
For example, the word zmbzmb
has a numerical value of 6560820
. The explanation is the following:
In the Googlon alphabet, the letters z
m
and b
are the first three. If we represent that
word in digits according to the previous rules, this would be its value: 012012
. As a last step, it is necessary
convert it to base 20. According to the previous rules, the conversion is done as follows:
(0∗1)+(1∗20)+(2∗202)+(0∗203)+(1∗204)+(2∗205)=6560820
Googlons consider a magic number (very rare) if it satisfies one property: numerical value It is divisible by 42 (answer for everything) and all the digits are different from each other. To consider Text A as a list of numbers (i.e. interpret each word as a number using the convention explained above), we notice that there are 8 magic numbers: kpbslq, gtrpzhwb, ghfntj, ljdz, gthkq, lbqjrp, jplzc and gjw.
And in Text B, how many magic numbers are there and what are they? Save in the variable num_magicos
the number of magic numbers there are in Text B, and in the variable magic
save what they are.
Remember: The texts are already defined, as is the order
variable from the previous exercise.
"""This function converts a word to its numerical value"""
Activity: 5 ActiveCode (ac_r02_5_en)